Exception as the primary error handling mechanism?
usenot at geekmail.INVALID
Fri Jan 1 15:01:32 CET 2010
On Fri, 01 Jan 2010 11:34:19 +0100 "Martin v. Loewis"
<martin at v.loewis.de> wrote:
> Your observation is not wrong, but, as Benjamin already explained,
> you are misinterpreting Michi Henning's statement. He doesn't condemn
> exception handling per se, but only for the handling of *expected*
> outcomes. He would consider using exceptions fine for *exceptional*
> output, and that is exactly the way they are used in the Python API.
May I point out at this point that "exceptional" does not mean
"unexpected"? You catch exceptions, not unexpectations. An exception
is rare, but not surprising. Case in point: StopIteration.
To put it differently: When you write "catch DeadParrot", you certainly
expect to get a DeadParrot once in a while -- why else would you get it
in your head to try and catch it? An unexpected exception is the one
that crashes your program.
More information about the Python-list