beginner python cgi question
reply.in.the.newsgroup at my.address.is.invalid
Sat Dec 13 11:26:12 CET 2003
> if (fields.has_key("name") and fields.has_key("emailaddr")):
>I think what the problem is that if my form does not have one of the
>fields (except 'name' and 'emailaddr') with data in it, I get this error.
>What is the best way to fix this?
One way is to use if has_key(), as you already discovered. The other way
is exception handling:
Address = fields["address"].value
except KeyError, e:
Address = None # and/or report an error
# do something with Address
More information about the Python-list