[CentralOH] Missing Exceptions?

Brian Costlow brian.costlow at gmail.com
Tue Dec 13 22:24:13 CET 2011

You can look at the doc for the module in question, or just trawl the

But that might not even help, because the source will show you exceptions
the module explicitly raises, but not all the ones that code the module
calls might raise.

But IMHO the zen of exceptions is to catch the ones you can handle and do
something about at a given point.

Otherwise, let them bubble up to something that can, especially if you're
writing module/library code that calls modules that you didn't write.

Even if you are writing an app, probably better to just catch what you can
handle in local try blocks, let everything else bubble, and catch anything
not handled elsewhere in main just so you can exit the app with a graceful
message to the user instead of dumping a stack trace.

On Tue, Dec 13, 2011 at 3:30 PM, <jep200404 at columbus.rr.com> wrote:

> I wrote:
>    try:
>        float(s)
>    except (ValueError):
> Later I realized that I had missed an exception,
> so the code was updated to:
>    try:
>        float(s)
>    except (ValueError, TypeError):  # !!! What exception names am I
> missing?
> How does one determine what all the relevant exceptions are?
> How does one conclude that the the list of exceptions is complete?
> Those questions are general, about all try/except stuff,
> not just my little example.
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20111213/a9c770c4/attachment.html>

More information about the CentralOH mailing list