[Python-ideas] syntax to continue into the next subsequent except block
Stephen J. Turnbull
stephen at xemacs.org
Tue Sep 18 03:08:54 CEST 2012
Steven D'Aprano writes:
> I don't think [the existing syntax] is quite awkward.
Of course it is. It doesn't fit the semantics, and that is why it is
awkward. An exception should be caught by an 'except' clause, not by
a conditional statement. As Antoine's refactoring demonstrates, these
Exceptions that are differentiated by an internal errno are often
conceptually a variety of different exceptions. I agree with the
suggestion that really we should fix up other Exceptions that are
clearly quite heterogeneous by subclassing more precise exceptions
from them.
But this isn't always possible, and of course may not be backward
compatible.
I don't know how to do it Pythonically, but it would be nice if there
were some way to "subclass Exceptions on the fly".
(other) Steve
More information about the Python-ideas
mailing list