How to define a GLOBAL Variable ?

Pete Shinners pete at shinners.org
Thu Aug 2 11:22:43 EDT 2001


"Peter Moscatt" <pmoscatt at iprimus.com.au> wrote
> If I wish to define a variable that I want to become global
> to ALL classes within a .py file - how is this best achieved ?

here's what i do when working on larger projects. i make a
separate file named "globals.py". in there you put all the
variables you want set with their default value. then any
module that must access the global variables just does
"import globals". then you access the members of globals
regularly, the variables will be shared across all modules.







More information about the Python-list mailing list