Exceptions as New Style Classes

Steven Taschuk staschuk at telusplanet.net
Thu Jul 31 08:06:17 CEST 2003


Quoth Carl Banks:
> Steven Taschuk wrote:
> > At the moment the dominant idea for solving these problems is to
> > make inheritance from Exception mandatory for exception types; see
  [...]
> Why not give exceptions their own metaclass?  So if type(x) is
> ExceptionMetaclass, it's a class.  If type(type(x)) is
> ExceptionMetaclass, it's an instance.  Otherwise, it's illegal to
> raise it.

That seems workable.  (I'd prefer, though, to test
    isinstance(type(x), ExceptionMetaclass)
and likewise for the second case.)

I'm not sure what it gains us, though, over the idea of mandatory
inheritance from Exception.  Am I missing something?

-- 
Steven Taschuk                  staschuk at telusplanet.net
"Telekinesis would be worth patenting."  -- James Gleick





More information about the Python-list mailing list