> 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 -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/TO7ZCRVTPKSUL5EJ76F2IOMGUBTYLA33/
Code of Conduct: http://python.org/psf/codeofconduct/