[Tutor] smtplib exceptions are based on Exception class

Lloyd Kvam pythonTutor at venix.com
Sat Aug 28 00:19:04 CEST 2004

On Fri, 2004-08-27 at 15:56, Kent Johnson wrote:
> AFAIK this is typical, e.g.
>  >>> import socket
>  >>> socket.error.__bases__
> (<class exceptions.Exception at 0x00764510>,)
>  >>> import zlib
>  >>> zlib.error.__bases__
> (<class exceptions.Exception at 0x00764510>,)
>  >>> import binhex
>  >>> binhex.Error.__bases__
> (<class exceptions.Exception at 0x00764510>,)
> It is also the style used in the Tutorial: 
> http://docs.python.org/tut/node10.html#SECTION0010500000000000000000

You're quite right.  I grepped for 'class.*(Error|Exception)' in the
standard lib and only urllib2 had defined exceptions NOT based on
Exception.  So only the core of the language actually lives by the
detailed Exception hierarchy, at least when creating new exceptions.

I looked through some of the modules I use heavily.  In general, they
simply raise ValueError or some other existing exception that fits the
context.  In the case of smtplib, I wish they used IOError as the base
for their new exceptions like urllib2 does.

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	320-210-3409 (changed Aug 26, 2004)

More information about the Tutor mailing list