Python style: exceptions vs. sys.exit()

Grant Edwards invalid at invalid
Wed Sep 24 11:54:40 EDT 2008


On 2008-09-24, Ross Ridge <rridge at csclub.uwaterloo.ca> wrote:
> Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> wrote:
>> Presumably somebody has suggested that calling sys.exit() was a good 
>> option. I'm curious to what possible reason they could give for such a 
>> poor choice.
>
> Grant Edwards  <invalid at invalid> wrote:
>>Same here.  It's like an automotive engine controls designer
>>asking if a failed O2 sensor should turn on the check engine
>>light or blow up the car.
>
> No, it's more like asking if the failed sensor should turn on
> a strange and mysterious light on the dashboard

You're right.  I had forgotten that sys.exit() is actually
raising the system exit exception, and that the application
calling the library could handle that exception.

> and then blow up the car if the driver doesn't immediately
> stop and check the engine.  The owners manual would only
> vaguely hint at the fact that this could happen.

-- 
Grant Edwards                   grante             Yow! Why is it that when
                                  at               you DIE, you can't take
                               visi.com            your HOME ENTERTAINMENT
                                                   CENTER with you??



More information about the Python-list mailing list