Python style: exceptions vs. sys.exit()
Grant Edwards
invalid at invalid
Tue Sep 23 17:18:11 EDT 2008
On 2008-09-23, Drake <cjdrake at gmail.com> 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 able to just dump to
> sys.exit() with a message about the error (like "couldn't open this
> file"),
No. A library module should never call sys.exit().
> or should the exception propagate to the calling program which
> handles the issue?
Yes. Let the application handle the error if it wants to. If
it's not handled, it'll end up causing the program to exit.
--
Grant Edwards grante Yow! It's a hole all the
at way to downtown Burbank!
visi.com
More information about the Python-list
mailing list