avoiding nested try/excepts

Steven Bethard steven.bethard at gmail.com
Fri Nov 19 12:29:00 EST 2004


Andrew Clover wrote:
> Steven Bethard <steven.bethard at gmail.com> wrote:
> 
>>         except:
>>             log(x)
>>             raise
> 
> 
> (Of course 'except:' is rarely a good idea! You probably want to
> exclude at least MemoryError - as log() might then fail - and possibly
> also KeyboardInterrupt, SystemExit depending on what you're doing.)

So what's the idiom for catching all exceptions *except* 
MemoryError/KeyboardInterrupt/SystemExit?  Too bad we won't get our new 
Exceptions hierarchy until Python 3000...

Steve



More information about the Python-list mailing list