How to except the unexpected?

Paul Rubin http
Sat Mar 4 08:41:11 CET 2006

Steven D'Aprano <steve at> writes:
> The way to deal with it is to add another except clause to deal with the
> KeyboardInterrupt, or to have recover_from_error_gracefully() deal with
> it. 

I think adding another except clause for KeyboardInterrupt isn't good
because maybe in Python 2.6 or 2.6 or whatever there will be some
additional exceptions like that and your code will break.  For example,
proposals have floated for years of adding ways for threads to raise
exceptions in other threads.

I put up a proposal for adding an AsynchronousException class to
contain all of these types of exceptions, so you can check for that.

> Oh, in case this also wasn't obvious, Donald Knuth won't really pay
> $327.68 for bugs in your Python code. He only pays for bugs in his own
> code. *wink*

The solution to that one is obvious.  We have to get Knuth using Python.
Anyone want to write a PEP?  ;-)

More information about the Python-list mailing list