> But if you use a context manager which silences the exception, like > contextlib.suppress() or unittest.TestCase.assertRaises(), it is easy to > do too. > > was_not_raised = False > with my_context(): > do_something_sensitive() > was_not_raised = True > if was_not_raised: > print("We're all safe.")
That is indeed a way to workaround my use case. I do still find a with/else more elegant. _______________________________________________ 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/TO7ZCRVTPKSUL5EJ76F2IOMGUBTYLA33/ Code of Conduct: http://python.org/psf/codeofconduct/