[Tutor] introspecting exceptions?

Isr Gish isrgish at fusemail.com
Thu Feb 12 00:01:01 EST 2004

-----Original Message-----
   >From: "Marilyn Davis"<marilyn at deliberate.com>
   >Sent: 2/11/04 6:03:16 PM
   >To: "tutor at python.org"<tutor at python.org>
   >Subject: [Tutor] introspecting exceptions?
   >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

The problem here is that you don't have exceptions in you're namespace.
Do this:
>>> import exceptions
>>> print exceptions.__doc__
Python's standard exception class hierarchy.

Before Python 1.5, the standard exceptions 
[sniped the output]

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

Checkout the tutorial chapter 8.

   >Thank you in advance.
   >Marilyn Davis
   >Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list