D
Dan Rawson
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
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