How do I declare global vars or class vars in Python ?

Paddy O'Loughlin patrick.oloughlin at
Tue Feb 17 10:13:38 EST 2009

2009/2/17 MRAB <google at>:
> It isn't possible to have an uninitialised variable. If it doesn't have
> a value then it doesn't exist.

True, but you can use the global statement to refer to the variable
within a function and read from the variable there, without it being
already initialised in the module.

Of course, if you try to call that function before the global has been
initialised, python will complain [and rightly so :)]


"Ray, when someone asks you if you're a god, you say YES!"

More information about the Python-list mailing list