subclassing Exceptions

Tim Peters tim.one at home.com
Mon Jul 23 00:00:30 EDT 2001


[phawkins at spamnotconnact.com]
> ...
> import exceptions
> ...
> class CameraError(exceptions.Exception):
>     def __init__ (self, args = None):
>         self.args = args

Just noting that Exception is in the builtin namespace, so there's no need
to import the exceptions module first.  That is, you can drop the import,
and change the declaration to

    class CameraError(Exception):

i-was-surprised-too-when-barry-taught-me-that!-ly y'rs  - tim





More information about the Python-list mailing list