Beginners question. I have started my iPython shell and I am running scripts with the run-command and everything works great. However running a script file and then editing a imported script file and then trying to run it again causes the old imported file to run. So I am guessing python saves some kind of cache for speed. I've tried clear command and such but to no avail.
Basically my problem is this. Two files: function.py and program.py. The program file imports the function. But running the program and then editing the function and then running the program again causes the old function/un-edited version to run.
Inside of iPython or the standard Python interpreter, you can use the reload()
function to reload an imported module.
Example:
In [1]: import foo
# make some changes to the foo.py
In [2]: reload(foo)
For Python 3.4 and above
import importlib
import foo
# Make changes on foo.py
importlib.reload(foo)
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