del behavior

Chris Rebert clp2 at rebertia.com
Wed Jan 7 15:15:21 EST 2009


On Wed, Jan 7, 2009 at 12:05 PM, MRAB <google at mrabarnett.plus.com> wrote:
> Chris Rebert wrote:
>>
>> On Wed, Jan 7, 2009 at 11:39 AM, Eric Snow <esnow at verio.net> wrote:
>>>
>>> I was reading in the documentation about __del__ and have a couple of
>>> questions.  Here is what I was looking at:
>>>
>>> http://docs.python.org/reference/datamodel.html#object.__del__
>>>
>>> What is globals referring to in the following text from that reference
>>> page?
>>
>> Globals are variables that have toplevel module scope. Basically, any
>> assignments, function definitions, or class definitions with no
>> indentation from the left margin will create a global variable. If you
>> can get at the variable by appending something of the form
>> "\nSomeIdentifierHere\n" to the module's file, and it's not a built-in
>> function, then it's a global.
>>
> Actually, the amount of indentation doesn't matter. What matters is whether
> it's within a 'def' or 'class' statement or not.

Yes, but those do require you *to indent* (though so do while & if for
that matter); I just couldn't seem to come up with a better
description of the rule at the time.
But you are correct and yours is a much better description of the rule.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list