SV: Python Productivity over C++

Steve Tregidgo smst at bigfoot.com
Thu Jun 15 03:20:32 EDT 2000


David Bolen wrote:
> 
[much of `verify_class' snipped]
>
>                 except AttributeError, TypeError:
>                     print "Method %s not supported" % curmethod

Note that this code won't pick up the TypeError -- to do that, make a
slight change:

    except (AttributeError, TypeError):

The second `argument' in an except clause is used to get the error that
was raised -- so the code you posted will assign the details of the
AttributeError in the name TypeError!  To catch multiple types of error,
you must list them all as the first argument in the except statement,
using a tuple as above.  (Note also that you can use multiple except
clauses to do different things depending on what error is raised).

Feeling-pedantic-this-morning-ly y'rs,
Steve 

-- 
Steve Tregidgo
Software Developer
http://www.businesscollaborator.com




More information about the Python-list mailing list