unboundlocalerror with cgi module

David Bear david.bear at asu.edu
Mon Apr 10 14:29:30 EDT 2006


I'm attempting to use the cgi module with code like this:

import cgi
fo = cgi.FieldStorage()
# form field names are in the form if 'name:part'
keys = fo.keys()
for i in keys:
        try:
                item,value=i.split(':')
        except NameError, UnboundLocalError:
                print "exception..."
                item,value=(None,None)
return(item,value)

However, the except block does not seem to catch the exception and an
unboundlocalerror is thrown anyway. What am I missing?
        
-- 
David Bear
-- let me buy your intellectual property, I want to own your thoughts --



More information about the Python-list mailing list