How to know when a variable is set

Emile van Sebille emile at fenx.com
Wed Nov 14 10:36:20 EST 2001


"-" <madsurfer2000 at hotmail.com> wrote in message
news:fef0a228.0111140715.24b5cfc7 at posting.google.com...
> How can I test if a variable has been given a value, or if it's undefined?

>>> try:
...     if q:
...             dowith(q)
... except NameError:
...     print "q doesn't exist"
...
q doesn't exist
>>>

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list