A Programming Idiom You've Never Heard Of 
A similar pattern that blew my mind when I first saw it was ruby's scoped open().<p>instead of<p><pre><code>  f = open "test.txt"
  print f.read
  f.close
</code></pre>
You can write<p><pre><code>  open "text.txt" do |f|
    print f.read
  end
</code></pre>
The file is automatically closed at the end of the block, and it also handles exceptions and so on. I find it also lines up better semantically with how I think about opening handles to things.<p>I believe Python also added something similar via the 'with' syntax. Not sure about other languages.