except AttributeError, TypeError:

Brian Gough bjg at network-theory.co.uk
Sun May 2 05:35:33 EDT 2004


Thorsten Kampe <thorsten at thorstenkampe.de> writes:

> What is the best way to except two errors, when the except handling in 
> both cases is the same?

The "except" keyword can take a list of exceptions in parentheses,

  except (AttributeError, TypeError):
     ...

See the "Errors and Exceptions" chapter in the Python tutorial for
more details and examples.

-- 
Brian Gough

Network Theory Ltd,
Publishing the Python Manuals --- http://www.network-theory.co.uk/



More information about the Python-list mailing list