In python, how to restore the function of os.chdir() if os.chdir = 'path' has been implemented
<p>In path setup, I wrongly wrote the code: os.chdir = '\some path', which turns the function os.chdir() into a string. Is there any quick way to restore the function without restarting the software? Thanks!</p>

<p>Kicking <code>os</code> out of the modules cache can make it freshly importable again:</p>

<pre><code>&gt;&gt;&gt; import sys, os
&gt;&gt;&gt; os.chdir = "d'oh!"
&gt;&gt;&gt; os.chdir()
TypeError: 'str' object is not callable
&gt;&gt;&gt; del sys.modules['os']
&gt;&gt;&gt; import os
&gt;&gt;&gt; os.chdir
&lt;function posix.chdir&gt;
</code></pre>

python