Python Global State
Hendrik van Rooyen
mail at microcorp.co.za
Wed Feb 4 01:54:35 EST 2009
er wrote:
>Simple question, I think: Is there a way to make a
>completely global variable across a slew of modules?
>If not, what is the canonical way to keep a global state?
>The purpose of this is to try to prevent circular module
>imports, which just sort of seems nasty. Thank you!
Take a leaf out of COBOL's data division book,
and make a module that has all the globals in it.
Just refrain from calling it globals, that is the
path to insanity.
Then whenever you need the stuff, just
import system_globals, and you are done.
This has another hidden advantage, in that the
system_globals.py can be used to keep all
sorts of system wide configuration information.
- Hendrik
More information about the Python-list
mailing list