I have a With statement that I'd like to skip if some <condition> is satisfied. That is, I write:
With MyContext() as mc:
do_something()
and
class MyContext(object):
...
def __enter__(self,...):
if <condition>:
JumpToExit()
def __exit__(self,...):
print('goodbye')
I would like do_something() to be executed only on certain conditions, otherwise I'd like JumpToExit() to skip the body entirely and just finish the block.
Thanks.