How to know when a variable is set

Skip Montanaro skip at pobox.com
Wed Nov 14 10:32:36 EST 2001


>> How can I test if a variable has been given a value, or if it's
>> undefined?

    try:
        x
    except NameError:
        pass

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
It's only a 25% solution to our problem.  Of course, if we only want to
solve 25% of our problem it becomes a 100% solution.




More information about the Python-list mailing list