Exceptional inheritance patterns (was Re: [Python-Dev] Python inUnicode context)

Robert Brewer fumanchu at amor.org
Thu Aug 5 17:34:43 CEST 2004

Holger Krekel wrote:
> Sure, i can probably wrap the result object into some class
> which inherits from Exception.  My point is that I like to
> regard try/except as a mechanism for "out-of-band" objects.
> Guidos "should be shot" seems to indicate he sees try/except
> only useful/applicable to exception-handling. 

Putting on my "language lawyer" hat:

"Exceptions are a means of breaking out of the normal flow of control of
a code block in order to handle errors or other exceptional conditions.
An exception is raised at the point where the error is detected; it may
be handled by the surrounding code block or by any code block that
directly or indirectly invoked the code block where the error occurred."

If "exception" is only meant for errors, then don't use it for
non-errors. But if "exception" is meant for "other exceptional
conditions", then why not use it for them? Sounds to me like you just
need to expand your use of the term "exception", and therefore, your use
of Exception(). ;)

Robert Brewer
Amor Ministries
fumanchu at amor.org

More information about the Python-Dev mailing list