In this regard, Python is pretty similar to Java. But the Python exception should be compared to Java Throwable.
As Throwables come in all sorts of flavors β Error, RuntimeException, and (checked) Exception β Python does the same (though not checked exceptions).
As for the language, the error is exceptional, so the inheritance hierarchy is not strange.
I especially don't like the name Exception. Exceptions are used not only for exceptional circumstances (for example, we hope errors), but also in order to simply exit the control flow. Because this is what makes the Exception; he jumps out of the normal control flow to the marked point. A bit like goto, but more sophisticated.
However, every time you have a situation where a suitable return value cannot be found, you usually use an exception. Both in Python and in Java.
extraneon May 25 '10 at 11:04 a.m. 2010-05-25 11:04
source share