title: Python 'with' command
body: <p>Is this code</p>
  
  <pre><code>with open(myfile) as f:
      data = f.read()
      process(data)
  </code></pre>
  
  <p>equivalent to this one</p>
  
  <pre><code>try:
      f = open(myfile)
      data = f.read()
      process(f)
  finally:
      f.close()
  </code></pre>
  
  <p>or the following one?</p>
  
  <pre><code>f = open(myfile)
  try:
      data = f.read()
      process(f)
  finally:
      f.close()
  </code></pre>
  
  <p>This article: <a href="http://effbot.org/zone/python-with-statement.htm" rel="nofollow">http://effbot.org/zone/python-with-statement.htm</a> suggests (if I understand it correctly) that the latter is true. However, the former would make more sense to me. If I am wrong, what am I missing?</p>