I have the following toy code in two files:
File b.py
:
def test_b():
print "b"
File a.py
:
from b import test_b
def test_a():
print "a"
test_b()
Then I run the python REPL:
>>> execfile("a.py")
>>> test_a()
a
b
Then I modify b.py
into:
def test_b():
print "bb"
And run in the REPL:
>>> execfile("b.py")
>>> test_a()
a
bb
For now it is all fine. Now I modify a.py
into:
from b import test_b
def test_a():
print "aa"
test_b()
Now I run into the REPL:
>>> execfile("a.py")
>>> test_a()
aa
b
Which is not fine anymore since the REPL got the older version of b.py
. Python seems to be doing some caching when loading the files, and my question is: is there a way to force it not to do that? I couldn't find a proper option for the function excefile
.