Is there a way to define a true global across modules?
alex23
wuwei23 at gmail.com
Sun Nov 5 20:18:05 EST 2006
Hendrik van Rooyen wrote:
> "robert" <no-spam at no-spam-no-spam.invalid> wrote:
> > Fredrik Lundh wrote:
> > > http://www.effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm
> > Or worse style - if you are too lazy to create a extra global variables module
> > (ab)use the __main__ module als "global":
> > import __main__
> > __main__.mysemphore += 1
> Thanks - how could you possibly have guessed that I am lazy - does it show that
> much? *WEG*
You could merge the two approaches and bind a more explicit name to
__main__:
import __main__ as config
config.mysemaphore = 0
It's a little clearer what you're subverting __main__ for here :)
- alex23
More information about the Python-list
mailing list