It is not clear whether error1, error2, etc. should be handled differently. If not, the following code will do the trick:
try: do_something() except (error1, error2, error3), exception_variable: handle_any_of_these_exceptions()
if you need to handle different errors in different ways, as well as have a common code, then in the except block you can have the code of the following type:
if isinstance(exception_variable, error1): do_things_specific_to_error1()
Davep
source share