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!
Kicking os
out of the modules cache can make it freshly importable again:
>>> import sys, os
>>> os.chdir = "d'oh!"
>>> os.chdir()
TypeError: 'str' object is not callable
>>> del sys.modules['os']
>>> import os
>>> os.chdir
<function posix.chdir>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With