Python Global State

MRAB google at
Tue Feb 3 11:10:32 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!
Simple answer: no.

You can put your global state into a module which is imported wherever 
it's needed:
foo = ""
import my_globals
... = "FOO"
import my_globals

More information about the Python-list mailing list