unboundlocalerror with cgi module
Fredrik Lundh
fredrik at pythonware.com
Mon Apr 10 15:32:36 EDT 2006
"David Bear" wrote:
> 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?
why on earth do you expect a string split to result in either a NameError
or an UnboundLocalError ? (both of which signify *programming* errors,
most likely in *your* code, and should be fixed rather than ignored)
</F>
More information about the Python-list
mailing list