[Python-Dev] Proposed resolutions for open PEP 343 issues
Michael Chermside
mcherm at mcherm.com
Wed Oct 26 17:32:46 CEST 2005
Guido writes:
> I find "AttributeError: __exit__" just as informative.
Eric Nieuwland responds:
> I see. Then why don't we unify *Error into Error?
> Just read the message and know what it means.
> And we could then drop the burden of exception classes and only use the
> message.
> A sense of deja-vu comes over me somehow ;-)
The answer (and there _IS_ an answer) is that using different exception
types allows the user some flexibility in CATCHING the exceptions. The
discussion you have been following obscures that point somewhat because
there's little meaningful difference between TypeError and
AttributeError (at least in well-written code that doesn't have
unnecessary typechecks in it).
If there were a significant difference between TypeError and
AttributeError then Nick and Guido would have immediately chosen the
appropriate error type based on functionality rather than style, and
there wouldn't have been any need for discussion.
Oh yeah, and you can also put extra info into an exception object
besides just the error message. (We don't do that as often as we
should... it's a powerful technique.)
-- Michael Chermside
More information about the Python-Dev
mailing list