update file descriptor after os.rename()
<p>What is the best way to handle <code>Bad file descriptor</code> errors after calling <code>os.rename()</code> in the following manner?</p>

<pre><code>f = open('foo.txt', 'rw')
os.rename(f.name, f.name + ".bak")
</code></pre>

<p>In the file system there is no longer a <code>foo.txt</code> but instead a <code>foo.txt.bak</code></p>

<p>However..</p>

<pre><code>f.name
</code></pre>

<p>gives <code>foo.txt</code> instead of <code>foo.txt.bak</code></p>

<p>But..</p>

<pre><code>f.write("test")
</code></pre>

<p>gives <code>Bad file descriptor</code></p>

<p>Is there a good way to update the file descriptor?</p>

<p>Should I still call <code>f.close()</code> even tho the file has been renamed?</p>
