On Sun, May 23, 2021, 12:02 PM Damian Shaw <damian.peter.s...@gmail.com> wrote:
> FYI, > > Something very similar already exists in the standard library, > contextlib.suppress: > https://docs.python.org/3/library/contextlib.html#contextlib.suppress > > It makes a nice 2+ liner for a lot of situations: > > with suppress(Exception): > ... > > Seems more flexible than OPs keyword suggestion as you can fit an entire > block of code in there, not just a single expression. And it's quite > semantically expressive. > > Damian > (he/him) > I agree this is better than a decorator or the OP's idea. Didn't know this existed but I'll definitely be making use of it. >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/OL26EVXX72QAMCYGS2NDMGJNIFPW4QNR/ Code of Conduct: http://python.org/psf/codeofconduct/