Exceptions as New Style Classes

Carl Banks imbosol at aerojockey.com
Thu Jul 31 01:16:36 CEST 2003


Steven Taschuk wrote:
> At the moment the dominant idea for solving these problems is to
> make inheritance from Exception mandatory for exception types; see
> Guido's 11 June post
>    <http://mail.python.org/pipermail/python-dev/2003-June/036162.html>
> for details.  (I have another idea involving a new special method
> '__raise__', but haven't worked out the details yet.)


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.


-- 
CARL BANKS







More information about the Python-list mailing list