title: zen of Python vs with statement - philosophical pondering
body: <p>I don't intend to simply waste your time, but: <strong>has it occurred to you too, while using Python's <code>with</code> statement that it really is contrary to the 5th line of "The Zen of Python" that goes "Flat is better than nested"? Can any enlightened Python guru share me some of their  insights on this?</strong></p>
  
  <p>(I always find that one more level of indentation pops up in my code every time I use <code>with</code> instead of <code>f.close()</code>... and it's not like I'm not gonna use <code>try: ... finally: ...</code> anyways and thus the benefits of <code>with</code> still elude me, even as I grow to like and understand Python more and more...)</p>
  
  <hr>
  
  <p>@glglgl (sorry, I can't find a way to write code in comments):
  yes, but if you go the <code>with</code> way, your code becomes:</p>
  
  <pre><code>try:
      with file(...) as f:
          ...
  except IOError:
      ...
  </code></pre>
  
  <p>...and using just with without the <code>try</code> is what people end up doing in the type of hacky "one use" code where they use <code>f.close()</code> instead of with anyways (which is bad because the file may not be closed if an exception is thrown before their <code>f.close()</code>), so for "hacky" code people just don't use <code>with</code> because, I don't know, I guess they just find it too "fancy" and for well structured code it doesn't bring any benefits anyways, so it seems to me there's no real world use case left for it... that was my pondering about really.</p>