Python 2.6 Global Variables

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Fri Oct 30 11:38:20 CET 2009


Bruno Desthuilliers a écrit :
> AK Eric a écrit :
>>> 2/ in Python, "global" really means "module-level" - there's nothing
>>> like a "true" global namespace.
>>
>> Isn't that __main__?
> 
> Nope
> 
>>
>> import __main__
>> __main__.foo = "asdfasdf"
>>
>> print foo
>> # asdfasdf
>>
>> Not advocating, but it does serve the purpose.
> 
> This won't make 'foo' available to other imported modules.

Err, reading Steven and Gabriel's posts, it looks like I'm wrong and 
your right. Duh :(

You really shouldn't show this to childrens.



More information about the Python-list mailing list