Dealing with exceptions
steve+comp.lang.python at pearwood.info
Sun Mar 3 01:41:09 CET 2013
On Sat, 02 Mar 2013 18:52:19 +0100, Kwpolska wrote:
> Also, you can do `except:` for a catch-all, but it is discouraged unless
> you have REALLY good reasons to do this. And, most of the time, you
`except Exception` is to be much preferred over a bare except. It
excludes KeyboardInterruptError (the user hits Ctrl-C) and SystemExit,
which you normally either want to let through, or handle separately.
But yes, in general, only catch the minimum you *know* you need to catch
and can deal with. Anything else is a bug in your code that needs to be
fixed, and you can't fix it if you never see the exception.
More information about the Python-list