I\'d just like to exit out of a with statement under certain conditions:
with
with open(path) as f: print \'before condition\' if
I think you should just restructure the logic:
with open(path) as f: print 'before condition checked' if not : print 'after condition checked'