[Tutor] introspecting exceptions?

Marilyn Davis marilyn at deliberate.com
Wed Feb 11 18:03:16 EST 2004

Hello Python Experts,

I'm looking for a way to introspect exceptions.

dir() gives, amongst other things, a list of exceptions.

I can do these things:

>>> ZeroDivisionError.__doc__
'Second argument to a division or modulo operation was zero.'
>>> dir(ZeroDivisionError)
['__doc__', '__getitem__', '__init__', '__module__', '__str__']
>>> ZeroDivisionError.__module__
>>> exceptions.__doc__
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'exceptions' is not defined

I'm hoping to find the hierarchy of exceptions somehow.

Thank you in advance.

Marilyn Davis

More information about the Tutor mailing list