Test the existence of a variable?
meldron at meldron.org
Fri Sep 3 13:34:34 CEST 2004
Robin Becker wrote:
> Thierry S. wrote:
>> I would to test the existence of a variable before to use it (like
>> isset($myVar) in PHP).
>> I try using "if myVar: ", but there is the error meesage (naturally):
>> "NameError: name 'myVar' is not defined"
>> Please, could you tell me what for function exist to test the variable with
> if globals().has_key('myVar'):
I was once told, that in Python you do something and live with the
except NameError, e:
More information about the Python-list