global var

Jeff Shannon jeffshannon at gmail.com
Tue Feb 22 01:31:24 EST 2005


Nick Coghlan wrote:

> Michael Hoffman wrote:
> 
>> raver2046 wrote:
>>
>>> How to have a global var in python ?
>>
>> "global var" will give you a global variable named "var".
> 
> Whether this advice is correct or not depends greatly on what the OP 
> means by 'global' :)
> 
> Module global, it's right, application global it's wrong. Given the 
> nature of the question, I suspect the latter.

And even there, one must be careful.  "global var" won't really give you 
a global variable; it will cause the name "var", when used locally, to 
refer to a pre-existing module-level reference "var".  No variables are 
actually created in the execution of "global var".

Jeff Shannon



More information about the Python-list mailing list