Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 09:15:35 -0500, Grant Edwards wrote: > On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: >> Lawrence D'Oliveiro wrote: >>> In message <[EMAIL PROTECTED]>, Steven >>> D'Aprano wrote: >>> >>> > (2) Even when the source is available, it is sometimes a legal trap >>> > to read it wit

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Grant Edwards
On 2008-10-03, J. Cliff Dyer <[EMAIL PROTECTED]> wrote: > > On Fri, 2008-10-03 at 09:15 -0500, Grant Edwards wrote: >> On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: >> > Lawrence D'Oliveiro wrote: >> >> In message <[EMAIL PROTECTED]>, Steven D'Aprano >> >> wrote: >> >> >> >> > (2) Even when the s

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread J. Cliff Dyer
On Fri, 2008-10-03 at 09:15 -0500, Grant Edwards wrote: > On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: > > Lawrence D'Oliveiro wrote: > >> In message <[EMAIL PROTECTED]>, Steven D'Aprano > >> wrote: > >> > >> > (2) Even when the source is available, it is sometimes a legal trap to > >> > read i

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Grant Edwards
On 2008-10-03, greg <[EMAIL PROTECTED]> wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Steven D'Aprano >> wrote: >> >> > (2) Even when the source is available, it is sometimes a legal trap to >> > read it with respect to patents and copyright. >> >> That's not how patents

Re: Python style: exceptions vs. sys.exit()

2008-10-03 Thread Steven D'Aprano
On Fri, 03 Oct 2008 17:09:07 +1200, greg wrote: > Lawrence D'Oliveiro wrote: >> In message <[EMAIL PROTECTED]>, Steven >> D'Aprano wrote: >> >> > (2) Even when the source is available, it is sometimes a legal trap >> > to read it with respect to patents and copyright. >> >> That's not how patent

Re: Python style: exceptions vs. sys.exit()

2008-10-02 Thread greg
Lawrence D'Oliveiro wrote: In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > (2) Even when the source is available, it is sometimes a legal trap to > read it with respect to patents and copyright. That's not how patents work. I don't think that's how copyrights work either. As far as I

Re: Python style: exceptions vs. sys.exit()

2008-09-30 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Mon, 29 Sep 2008 18:27:22 +0200, Bruno Desthuilliers wrote: Lawrence D'Oliveiro a écrit : In message <[EMAIL PROTECTED]>, Ross Ridge wrote: You need either use trial and error to find out, or look at the source. So what's wrong with using the source as documenta

Re: Python style: exceptions vs. sys.exit()

2008-09-29 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Steven D'Aprano wrote: > (1) It's not always available. But we're talking about Python libraries here, right? > (2) Even when the source is available, it is sometimes a legal trap to > read it with respect to patents and copyright. That's not how patents work. --

Re: Python style: exceptions vs. sys.exit()

2008-09-29 Thread Steven D'Aprano
On Mon, 29 Sep 2008 18:27:22 +0200, Bruno Desthuilliers wrote: > Lawrence D'Oliveiro a écrit : >> In message <[EMAIL PROTECTED]>, Ross Ridge wrote: >> >>> You need either use trial and error to find out, or look at the >>> source. >> >> So what's wrong with using the source as documentation? :)

Re: Python style: exceptions vs. sys.exit()

2008-09-29 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message <[EMAIL PROTECTED]>, Ross Ridge wrote: You need either use trial and error to find out, or look at the source. So what's wrong with using the source as documentation? :) Don't know... Ok, having higher-level documentation (the big picture, and quic

Re: Python style: exceptions vs. sys.exit()

2008-09-29 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Ross Ridge wrote: > You need either use trial and error to find out, or look at the source. So what's wrong with using the source as documentation? :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python style: exceptions vs. sys.exit()

2008-09-28 Thread Lie
On Sep 25, 3:05 pm, Bruno Desthuilliers wrote: > 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. > >>  T

Re: Python style: exceptions vs. sys.exit()

2008-09-26 Thread Ross Ridge
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > 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 obj

Re: Python style: exceptions vs. sys.exit()

2008-09-26 Thread Bruno Desthuilliers
Ross Ridge a écrit : Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: 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 wh

Re: Python style: exceptions vs. sys.exit()

2008-09-25 Thread Ross Ridge
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >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

Re: Python style: exceptions vs. sys.exit()

2008-09-25 Thread Ross Ridge
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

Re: Python style: exceptions vs. sys.exit()

2008-09-25 Thread Bruno Desthuilliers
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() af

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Steven D'Aprano
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

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Steven D'Aprano
On Wed, 24 Sep 2008 10:54:40 -0500, Grant Edwards wrote: > 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. Could but shouldn't. The exception hierarchy was re-designed in P

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Craig Allen
> Why, yes, I am wearing my BOFH hat. How could you tell? > > -- > Tim Rowe evil, but I think you may be a BSEFH, not a BOFH. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Ross Ridge
Grant Edwards <[EMAIL PROTECTED]> 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. Ross Ridge <[EMAIL PROTECTED]> wrote: > No, it's more like asking if the failed sensor should turn on

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Bruno Desthuilliers
Ross Ridge a écrit : (snip) Grant Edwards <[EMAIL PROTECTED]> 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. Ross Ridge <[EMAIL PROTECTED]> wrote: No, it's more like asking if the fail

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Ross Ridge
Steven D'Aprano <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> wrote: >Same here. It's like an automotive engine controls

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Grant Edwards
On 2008-09-24, Ross Ridge <[EMAIL PROTECTED]> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Ross Ridge
Steven D'Aprano <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> wrote: >Same here. It's like an automotive engine controls

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Tim Rowe
2008/9/24 Bruno Desthuilliers <[EMAIL PROTECTED]>: > Drake a écrit : >> many of the library functions to raise IOError Exceptions. The >> question is: should the library function be able to just dump to >> sys.exit() with a message about the error (like "couldn't open this >> file"), > > Arrghll !

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Grant Edwards
On 2008-09-24, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 23 Sep 2008 13:25:26 -0700, Drake wrote: > >> I have a general question of Python style, or perhaps just good >> programming practice. >> >> My group is developing a medium-sized library of general-purpose Python >> functions, som

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Carl Banks
On Sep 23, 4:25 pm, Drake <[EMAIL PROTECTED]> wrote: > The > question is: should the library function be able to just dump to > sys.exit() with a message about the error (like "couldn't open this > file"), I'm kind of curious what your library is for. Is it something where exiting the app be the

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Bruno Desthuilliers
Drake a écrit : I have a general question of Python style, or perhaps just good programming practice. My group is developing a medium-sized library of general-purpose Python functions, some of which do I/O. Therefore it is possible for many of the library functions to raise IOError Exceptions. T

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Asun Friere
On Sep 24, 8:10 am, Christian Heimes <[EMAIL PROTECTED]> wrote: > Side note: > > sys.exit() is just another way to write raise SystemExit. The function > is defined as: > As can be seen if you were ever silly enough to call sys.exit() in IDLE. ;) -- http://mail.python.org/mailman/listinfo/python-

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Steven D'Aprano
On Tue, 23 Sep 2008 13:25:26 -0700, Drake wrote: > I have a general question of Python style, or perhaps just good > programming practice. > > My group is developing a medium-sized library of general-purpose Python > functions, some of which do I/O. Therefore it is possible for many of > the libr

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Christian Heimes
Drake wrote: I have a general question of Python style, or perhaps just good programming practice. My group is developing a medium-sized library of general-purpose Python functions, some of which do I/O. Therefore it is possible for many of the library functions to raise IOError Exceptions. The

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Terry Reedy
Drake wrote: I have a general question of Python style, or perhaps just good programming practice. My group is developing a medium-sized library of general-purpose Python functions, some of which do I/O. Therefore it is possible for many of the library functions to raise IOError Exceptions. The

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Craig Allen
> The > question is: should the library function be able to just dump to > sys.exit() with a message about the error (like "couldn't open this > file"), or should the exception propagate to the calling program which > handles the issue? > my view is that the exceptions are there precisely to tell

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Grant Edwards
On 2008-09-23, Drake <[EMAIL PROTECTED]> wrote: > My group is developing a medium-sized library of general-purpose > Python functions, some of which do I/O. Therefore it is possible for > many of the library functions to raise IOError Exceptions. The > question is: should the library function be a

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Larry Bates
Drake wrote: I have a general question of Python style, or perhaps just good programming practice. My group is developing a medium-sized library of general-purpose Python functions, some of which do I/O. Therefore it is possible for many of the library functions to raise IOError Exceptions. The

Python style: exceptions vs. sys.exit()

2008-09-23 Thread Drake
I have a general question of Python style, or perhaps just good programming practice. My group is developing a medium-sized library of general-purpose Python functions, some of which do I/O. Therefore it is possible for many of the library functions to raise IOError Exceptions. The question is: sh