Python style: exceptions vs. sys.exit()

Ross Ridge rridge at csclub.uwaterloo.ca
Thu Sep 25 16:59:43 EDT 2008


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.

Steven D'Aprano  <steve at REMOVE-THIS-cybersource.com.au> wrote:
>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.

The problem is that few Python libraries properly document where and
when they might generate exceptions.  They'll document the fact that
they have an "error" exception, but only vaguely say which functions or
methods could generate it and why.  You need either use trial and error
to find out, or look at the source.

					Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge at csclub.uwaterloo.ca
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //	  



More information about the Python-list mailing list