trouble testing for existance of variable

Cliff Wells logiplexsoftware at earthlink.net
Tue Mar 12 17:26:56 EST 2002


On 12 Mar 2002 13:52:01 -0800
googlePoster wrote:

> if I want to know if a variable exists before
> testing it, what do I do?

How about 

try:
   colors_name
except NameError:
   print "it doesn't exist"
else:
   print "it exists"

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308




More information about the Python-list mailing list