subclassing Exceptions

Sheila King sheila at spamcop.net
Sun Jul 22 00:44:44 EDT 2001


On Sat, 21 Jul 2001 20:49:01 -0700, "Brian Quinlan" <brian at sweetapp.com>
wrote in comp.lang.python in article
<mailman.995773776.14791.python-list at python.org>:

:> I tried looking under the /Python20 directory for source or something
:> for the Exception classes, but can't find it. For example, right now
:> I'm working on subclassing the rfc822.py module, and I found the file
:> rfc822.py in /Python20/Lib and studied the source until I understood
:> it, and could subclass it. I'd like to find something similar for the
:> standard exception classes. I looked in the /include directory and
:> some others but can't find what I'm needing.
:
:Check out http://www.python.org/doc/current/lib/module-exceptions.html
:

Thanks, Brian, but I've seen the docs many times. I need more info than
that. Like example code, or source code.

However, someone else gave me some pointers.

If I want to see the actual source for the exceptions.c class, I can
browse at sourceforge.net here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/

I found the exceptions.c file here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Python/exceptions.c

However, I may not need that much detail and background. Maybe a few
examples of subclassing exceptions in Python would do. So, one might
want to look at these:

See the source for this module:
http://python.org/doc/current/lib/module-xml.sax.html
(although, later thought to possibly be a bit complicated)

or

How about viewing the source for the ConfigParser.py module.

Anyhow, I've looked a bit over the exceptions.c file, which is
interesting. Now I'm off to study the source for the (above) suggested
Python modules, as examples of subclassing exceptions.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/





More information about the Python-list mailing list