[Python-Dev] Re: PEP-317
Guido van Rossum
guido@python.org
Mon, 09 Jun 2003 15:03:08 -0400
> I guess I'm missing why this wouldn't work for new-style exceptions,
> provided they are required to subclass Exception (which I thought
> everything was going to be required to do eventually).
I'm dithering on that, actually. It's a Java vs. C++ thing: in C++
you can raise any type, in Java it must be an Exception instance.
Python usually doesn't care about isinstance relationships but cares
about whether the needed protocol is implemented, and this suggests
that requiring exceptions to subclass Exception is unPythonic.
But at other times, the desire to catch bogus arguments to raise
suggests that the subclass requirement might be just fine, and I don't
have a use case that breaks with this requirement (since you can
always use multiple inheritance to make a desirable class raisable).
--Guido van Rossum (home page: http://www.python.org/~guido/)