Exceptions, assigning a tuple

Derek Fountain nomail at hursley.ibm.com
Fri Nov 21 08:03:44 CET 2003

This came up in another thread, but I thought it was worth asking to the
group in a thread of its own.

What I don't understand is the assignment of a tuple in the except clause.
The O'Reilly Nutshell book says "The optional target is an identifier that
names a variable that Python binds to the exception object just before the
exception handler executes". This doesn't make sense in this case:

except IOError, (errno, strerror):

The target is a tuple of 2 variable names so how can it bind "the exception
object" to them? The documentation for try/except says that "the
exception's parameter is assigned to the target". So what, exactly, is an
"exception's parameter"?

More information about the Python-list mailing list