The definitive document is PEP-3110: Catching Exceptions
Summary:
- In Python 3.x, using
asis required to assign an exception to a variable. - In Python 2.6+, use the
assyntax, since it is far less ambiguous and forward compatible with Python 3.x. - In Python 2.5 and earlier, use the comma version, since
asisn’t supported.