title: Is `txt = open('file.txt').read()` worse than `with open('file.txt') as fh: txt = fh.read()`?
body: <p>In other words, when would Python close the file in first example? Would it be done immediately after reading from a file and realizing than there's no references to the file handler returned by <code>open('file.txt')</code>? If that's the case, it seems that <code>with</code> statement is not necessary here. Are there any caveats?</p>