title: how to get content of a small ascii file in python?
body: <p>Let's say we want to implement an equivalent of the PHP's <a href="http://fr2.php.net/manual/en/function.file-get-contents.php" rel="noreferrer"><code>file_get_content</code></a>.</p>
  
  <p>What is the best practice? (elegant and reliable)</p>
  
  <p>Here are some proposition, are they correct?</p>
  
  <p>using <code>with</code> statement:</p>
  
  <pre><code>def file_get_contents(filename):
      with file(filename) as f:
          s = f.read()
      return s
  </code></pre>
  
  <p>is using standard <code>open()</code> safe?</p>
  
  <pre><code>def file_get_contents(filename):
      return open(filename).read()
  </code></pre>
  
  <p>What happens to file descriptor in either solution?</p>