title: finally versus atexit
body: <p>I end up having to write and support short python wrapper scripts with the following high-level structure:</p>
  
  <pre><code>try:
      code
      ...
      ...
  except:
      raise
  finally:
      file_handle.close()
      db_conn.close()
  </code></pre>
  
  <p>Notice that all I do in the <code>except</code> block is re-raise the exception <strong>to the script caller</strong> sans window-dressing; this is not a problem in my particular context. The idea here is that cleanup code should always be executed by means of the <code>finally</code> block, exception or not.</p>
  
  <p>Am I better off using an <code>atexit</code> handler for this purpose? I could do without the extra level of indentation introduced by <code>try</code>.</p>