Why is there no function to read/write a file in the Python standard library
<p>I frequently use the two functions below to read the contents of a file to a string and to write a string to a file. To my knowledge these functions don't exist in the Python standard library and I'm curious why. The standard library module <a href="http://docs.python.org/library/shutil.html" rel="nofollow">shutil</a> which has high level directory and files operations does not have this function, and I'm sure this was an explicit design choice not to have it in there. Namely I'd like to know the following:</p>

<ul>
<li>What are the potential reasons for not including it in Python Standard Library</li>
<li>Are there any downsides to dealing with files this way (assuming one is aware that the whole file contents will be loaded into  memory)</li>
</ul>

<p><strong>functions</strong></p>

<pre><code>def read_file(path):
    with open(path) as f:
        return f.read()

def write_file(path, data):
    with open(path, 'wb') as f:
        return f.write(data)
</code></pre>

<p>To clarify I find the below more readable</p>

<pre><code>write_file('/tmp/test', 'test')
</code></pre>

<p>then the below two alternatives:</p>

<pre><code>open('/tmp/test', 'wb').write('test')

with open('/tmp/test', 'wb') as f:
    f.write(data)
</code></pre>
