global variables
Steven Bethard
steven.bethard at gmail.com
Wed Feb 2 19:23:40 EST 2005
M.E.Farmer wrote:
> alex wrote:
>> is it possible to create 'global' variables that can be seen in all
>> other classes?
>
> What about using a class?
>
> Py> class globalVar:
> ... pass
>
> Py> globals = globalVar()
Probably naming it something other than 'globals' would be a good idea
-- otherwise you'll hide the builtin globals() function.
But I agree that the attributes of a class instance (as you suggest) or
the attributes of a module (as Steve Holden suggests) is probably the
right way to go.
Steve
More information about the Python-list
mailing list