imaplib & except

Donn Cave donn at u.washington.edu
Thu Oct 5 13:43:57 EDT 2000


Following myself up -

I wondered why str(IMAP4.error) yields 'imaplib.error', and it turns
out this is a general property of class objects.  Regardless of the
scope in which a class is defined, its name is built from its __module__
attribute.  It's possible to modify that attribute, and it might even
be a good idea for folks who do something like this (an exception class
in class scope.)

      class A:
          class B:
              pass
          B.__module__ = '%s.%' % (__name__, 'A')

That's obviously hackery of the low sort, but it looks safe enough to
me - can't see any place __module__ is used for anything but display.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list