[Tutor] except AttributeError, TypeError:
dyoo at hkn.eecs.berkeley.edu
Sat May 1 20:24:08 EDT 2004
On Sun, 2 May 2004, Thorsten Kampe wrote:
> What is the best way to except two errors, when the except handling in
> both cases is the same?
Ah! There's an slightly cleaner way to do this. Let's say that we have
Here's another way to write the same thing:
except (AttributeError, TypeError):
We are allowed to pass a tuple of exceptions that we want to handle
uniformly. The Official Python Tutorial covers this usage here:
and it shows another way to do a kind of 'wildcarding' except clause that
If you have more questions, please feel free to ask. Good luck!
More information about the Tutor