I'd just like to exit out of a with statement under certain conditions: with open(path) as f: print 'before condition' if <condition>: break #syntax error! print 'after condition' Of course, the above doesn't work. Is there a way to do this? (I know that I can invert the condition: if not <condition>: print 'after condition' -- any way that is like above?) Continue reading...