Checking for an "undefined" variable - newbie question
Dan Rawson
daniel.rawson.take!this!out! at asml.nl
Wed Aug 6 06:47:34 EDT 2003
How do I check if a variable has been defined??
The following don't appear to work:
if variable:
if variable is None:
I have only one (ugly) solution:
try:
variable
except NameError:
...
which works, but is a bit clumsy if I just want to know if the thing already exists.
If there's a more elegant way to check this, that would be great!
Thanks . . . .
Dan
More information about the Python-list
mailing list