Python program termination and exception catching

Jason Swails jason.swails at gmail.com
Sun Apr 10 15:25:41 EDT 2011


Hello everyone,

This may sound like a bit of a strange desire, but I want to change the way
in which a python program quits if an exception is not caught.  The program
has many different classes of exceptions (for clarity purposes), and they're
raised whenever something goes wrong.  Most I want to be fatal, but others
I'd want to catch and deal with.

Is there any way to control Python's default exit strategy when it hits an
uncaught exception (for instance, call another function that exits
"differently")?

An obvious way is to just catch every exception and manually call that
function, but then I fill up my script with trys and excepts which hurts
readability (and makes the code uglier) and quashes tracebacks; neither of
which I want to do.

Any thoughts?

Thanks!
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110410/73835d0f/attachment.html>


More information about the Python-list mailing list