Checking for an "undefined" variable - newbie question

Dan Rawson daniel.rawson.take!this!out! at
Wed Aug 6 12:47:34 CEST 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:

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 . . . .


More information about the Python-list mailing list