How can I tell if variable is defined

Grant Edwards invalid at invalid.invalid
Tue Sep 22 20:58:14 CEST 2009

On 2009-09-22, Brown, Rodrick <rodrick.brown at> wrote:

> How could I do the following check in Python
> In Perl I could do something like if ((defined($a)) { ... }

except NameError:
    print "undefined"
    print "defined"

> I tried if var is not None:
> However this doesn't seem to work as described.

As described where?

Grant Edwards                   grante             Yow! I feel like a wet
                                  at               parking meter on Darvon!

More information about the Python-list mailing list