If I return inside a with block is the file guaranteed to close?
<p>Take the following code</p>

<pre><code>with open(path, mode) as f:
    return [line for line in f if condition]
</code></pre>

<p>Will the file be closed properly, or does return somehow bypass the context manager?</p>

<p>(Python 2.7)</p>
