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

Paddy O'Loughlin patrick.oloughlin at gmail.com
Tue Feb 17 16:13:38 CET 2009


2009/2/17 MRAB <google at mrabarnett.plus.com>:
> 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 :)]

Paddy

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



More information about the Python-list mailing list