I\'d just like to exit out of a with statement under certain conditions:
with
with open(path) as f: print \'before condition\' if
as shorthand snippet:
class a: def __enter__(self): print 'enter' def __exit__(self ,type, value, traceback): print 'exit' for i in [1]: with a(): print("before") break print("after")
...
enter before exit