Comparison with False - something I don't understand

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Dec 3 01:46:22 EST 2010


On Thu, 02 Dec 2010 16:35:08 +0000, Mark Wooding wrote:

>> 3. Philosophically I think exception handling is the wrong approach to
>> error management.
> 
> There are better ways to handle errors than Python's exception system.

I'm curious -- what ways would they be?

I'm aware of three general exception handling techniques:

1. return a sentinel value or error code to indicate an exceptional case 
(e.g. str.find returns -1);

2. raise an exception (e.g. nearly everything else in Python);

3. set an error code somewhere (often a global variable) and hope the 
caller remembers to check it;

plus some de facto techniques sadly in common use:

4. dump core;

5. do nothing and produce garbage output.


What else is there?


-- 
Steven



More information about the Python-list mailing list