Instance Exception Oddity: Implicit and Explicit not the same?

Shalabh Chaturvedi shalabh at gameboard.org
Wed Dec 10 19:11:06 EST 2003


whiteywidow at yahoo.com (rt lange) wrote in message news:<b771ffdd.0312091423.d1acc66 at posting.google.com>...

> *hmmm "Exception" did NOT become the TYPE of the exception*

One could argue that Exception is in fact the type of the exception.

>>> import sys
>>> class E(Exception):
...     pass
...
>>> try:
...     raise Exception, i
... except:
...     print isinstance(sys.exc_info()[1], Exception)
...
True

It just so happens that the exception is also of type E. In fact
'except Exception:' will also catch the exception.

--
Shalabh




More information about the Python-list mailing list