Is there a way to define a true global across modules?
Hendrik van Rooyen
mail at microcorp.co.za
Fri Nov 3 16:37:21 CET 2006
I am struggling with this - I want to define a "system-wide" flag for use as a
It looks to me as if the only way to do it is to import all the modules that
need to access it into the main namespace using the " from whatever import * "
Is there a way to have one global object known to the main module as well as say
two imported modules by using the global statement in the three places, while
using the normal "import modname " form?
It looks as if the global statement just makes the name global to the module
where it is defined, and if I use the "import modname" form I end up with a
"local global" for each module, as well as one for the main module...
Can they be "merged' into one without sticking everything into the same
I can think of ways to work around this, but it gets a bit obfuscatory - it
would be nicer to have one name, one thing in all three places...
More information about the Python-list