del behavior

MRAB google at mrabarnett.plus.com
Wed Jan 7 21:05:33 CET 2009


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.



More information about the Python-list mailing list