Check undefined variable

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Tue Jul 30 11:24:57 EDT 2002


"Michael Grabietz" <michael.grabietz at img-online.de> wrote in message
news:3D46AD2E.709 at img-online.de...
> how is it possible to check whether a variable 'a' is undefined or not.
>
> e.g.:
>
> if a==NULL :                 # something like that
>      print 'a is undefined !'
>      else
>      print 'a already undefined !'

try:
    type(A)
    print 'A exists'
except NameError:
    print 'A doesn't exist'

--
Daniel Fackrell (unlearned at learn2think.org)
When we attempt the impossible, we can experience true growth.





More information about the Python-list mailing list