Python 2.6 Global Variables

Aahz aahz at
Sat Oct 31 00:37:56 CET 2009

In article <888b5e8f-1be5-4040-bc7a-45c2e16954fc at>,
AK Eric  <warpcat at> wrote:
>> 2/ in Python, "global" really means "module-level" - there's nothing
>> like a "true" global namespace.
>Isn't that __main__?
>import __main__
> = "asdfasdf"
>print foo
># asdfasdf

Actually, you're almost right, but it's an even WORSE idea than you

import __builtin__ = 'bar'

Kids, do *NOT* do this at home!  The reasons why are left as an exercise
for the reader.  ;-)
Aahz (aahz at           <*>

"You could make Eskimos emigrate to the Sahara by vigorously arguing --
at hundreds of screens' length -- for the wonder, beauty, and utility of
snow."  --PNH to rb in r.a.sf.f

More information about the Python-list mailing list