Writing CGI Programs in Python And now for something completely different... Python has a very extensive, well documented and portable module library that provides a large variety of useful functions. The Internet-related collection is particularly impressive, with modules to deal with everything from parsing and retrieving URL's to retrieving mail from POP servers and everything in between.
| Name: |
slacker |
| Subject: |
Better Way |
| Date: |
09-01-1999 01:49PM |
In one of the examples on Page 6 "Putting it all together," the author uses a series of try:/except: as a DevShed reader noted this can be accomplished easier with the following syntax:
if form.has_key('email'):
email = form['email'].value
else:
email = ''
Or even this:
email = ''
name = ''
mapping = {
'email':email,
'name':name}
for m in mapping.keys():
if form.has_key(m):
mapping[m] = form[m].value
Although either one of these options would probably be a better alternative to the syntax used in the article's example, the example does give a correct example on how to use try:/except: properly.
|
Other posts in this thread:
Reply to this post:
|
 |
Visit the Python Forum!
New On DevShed:
Hot Forum Topics:
|