Does a function like isset() exist in Python?

Esben Pedersen n.20.e5ke at spamgourmet.com
Thu Jun 23 00:18:47 EDT 2005


Patrick Fitzsimmons wrote:
> Hi,
> 
> I'm sure I should know this, but I can't find it in the manual.
> 
> Is there a function in Python like the function in PHP isset()?  It
> should take a variable name and return True or False depending on
> whether the variable is initialized.
> 
> Thanks for any help,
> Patrick

try:
   doDomething(myVar)
except NameError:
   print "myVar is not set"

/Esben



More information about the Python-list mailing list