Python Global State
gherron at islandtraining.com
Tue Feb 3 11:11:17 EST 2009
> 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?
But this might satisfy:
Create a module called, perhaps, global.py which contains your variables.
VarA = None
VarB = None
Then any module can import it and read/write the values.
global.VarA = ...
# and so forth
> The purpose of this is to try to prevent circular module imports,
> which just sort of seems nasty. Thank you!
I'm not sure how that will work.
More information about the Python-list