This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients alex, chris.jerdonek, cvrebert, ezio.melotti, loewis, ncoghlan, rhettinger
Date 2012-08-29.09:55:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
(Note: I'm not yet convinced this is a good idea. I'm definitely considering it, though)

As with many context managers, a key benefit here is in the priming effect for readers. In this code:

       # Whatever
    except (A, B, C):

the reader doesn't know that (A, B, C) exceptions will be ignored until the end. The with statement form makes it clear before you start reading the code that certain exceptions won't propagate:

    with ignored(A, B, C):
        # Whatever

I'm not worried that it makes things less explicit - it's pretty obvious what a context manager called "ignored" that accepts an arbitrary number of exceptions is going to do.

One other thing it does is interact well with ExitStack - you can stick this in the stack of exit callbacks to suppress exceptions that you don't want to propagate.
Date User Action Args
2012-08-29 09:55:28ncoghlansetrecipients: + ncoghlan, loewis, rhettinger, ezio.melotti, alex, cvrebert, chris.jerdonek
2012-08-29 09:55:28ncoghlansetmessageid: <>
2012-08-29 09:55:28ncoghlanlinkissue15806 messages
2012-08-29 09:55:27ncoghlancreate