Python style: exceptions vs. sys.exit()

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Thu Sep 25 10:05:20 CEST 2008

Steven D'Aprano a écrit :
> On Wed, 24 Sep 2008 17:11:28 -0400, Ross Ridge wrote:
>> Plenty of people were quick to say that the exception should be passed
>> through to the caller.  No one said this behaviour should be documented.
>>  There may be little practical difference bewteen calling sys.exit()
>> after printing an error and progating an exception if no one using the
>> library knows that it could generate that exception in those
>> circumstances.
> That's true, I didn't explicitly say that the library should be 
> documented. Nor did I say that it shouldn't be riddled with bugs. There's 
> little practical difference between a buggy library and one that raises 
> unexpected (i.e. undocumented) exceptions either.

Also note that there are quite a couples cases where the library authors 
themselves cannot predict which exception types may be raised - as soon 
as the library functions expect callback functions, file-like or 
dict-like or whatever-like objects etc, it's the caller's responsability 
to handle the exceptions that may be raised by what *he* passes to the 

More information about the Python-list mailing list