Newbie: is a variable defined?

Christopher Swingley cswingle at iarc.uaf.edu
Sat Dec 21 18:33:04 EST 2002


Thanks to all who replied in this thread.  I got two excellent methods 
(use a try: except: block, or initialize to None and then test using is 
not None), and the background and rationale behind each.  Thanks!

> BTW, I trust you're not spamming anyone :-), that would be very
> unpythonic because we're nice people here,

Nope.  I maintain a web-accessible database of email posts to a list 
devoted to old woodworking tools (with the email addresses in the 
archive obscured as cswingle at ia...).  A list member sent me a list of 
messages and I needed to test each to see if it was already present in 
my existing archive and find the primary key if it was.  One of the 
tests I used was needed the username portion of the email address (the 
cswingle in the above example).

> I'm a lumberjack and I'm okay,
> I sleep all night and I work all day!

BTW, Sometimes I even use these old tools to cut down trees for use in 
my wood stove.

Chris
-- 
Christopher S. Swingley           email: cswingle at iarc.uaf.edu
IARC -- Frontier Program          Please use encryption.  GPG key at:
University of Alaska Fairbanks    www.frontier.iarc.uaf.edu/~cswingle





More information about the Python-list mailing list