Python 2.6 Global Variables
warpcat at sbcglobal.net
Fri Oct 30 00:11:37 CET 2009
> Good that you're not advocating it, because IMHO it's bad practice to
> have circular import dependencies. By using the __main__ alias, you
> avoid the worst problems, but that just means the others are more subtle.
I figured I'd get that kind of response, not that it's incorrect ;)
Great power\great responsibility\etc.
As I understand it, when you enter Python statements at the
interactive prompt, it's adding the result directly to ___main___
(which for lack of a better term I like to call 'universal' scope...
rolls off the tongue better than 'doubleunderscore main
>>> foo = 23
>>> import __main__
>>> print __main__.foo
While this might not be the most common way of working for most people
(I'm guessing most folks are in a nice cozy IDE), people working this
way are mucking about in the 'universal' scope without (possibly) even
More information about the Python-list