Author zaytsev
Recipients alex, barry, chris.jerdonek, cvrebert, eric.smith, ezio.melotti, jcea, loewis, ncoghlan, pitrou, python-dev, rhettinger, zaytsev
Date 2013-08-22.11:54:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1377172449.35.0.494389782273.issue15806@psf.upfronthosting.co.za>
In-reply-to
Content
Hi Raymond,

This is a brilliant idea, but before it hits the streets, couldn't you possibly consider extending it with a kwarg to control the depth of the exception stack?

The use case I have for that are snippets like this:

    with ignored(ValueError, TypeError), ignored(ValueError, TypeError), ignored(ValueError, TypeError):
        a()
        b()
        c()

Or else I could write this as

    with ignored(ValueError, TypeError):
        a()

    with ignored(ValueError, TypeError):
        b()

    with ignored(ValueError, TypeError):
        c()

... but either way it looks bad. This looks a bit better to me:

    with ignored(ValueError, TypeError, depth=3):
        a()
        b()
        c()

If you deem this to be unacceptably unpythonic, then please ignore my suggestion.
History
Date User Action Args
2013-08-22 11:54:09zaytsevsetrecipients: + zaytsev, loewis, barry, rhettinger, jcea, ncoghlan, pitrou, eric.smith, ezio.melotti, alex, cvrebert, chris.jerdonek, python-dev
2013-08-22 11:54:09zaytsevsetmessageid: <1377172449.35.0.494389782273.issue15806@psf.upfronthosting.co.za>
2013-08-22 11:54:09zaytsevlinkissue15806 messages
2013-08-22 11:54:09zaytsevcreate