Consider the following Python (2.7.9) code:
test.py
import test2
import time
while True:
    print test2.getData()
    time.sleep(1)
test2.py
def getData ():
    return [1,2,3]
Running with:
python -u test.py
If I modify test2.py while test.py is running (say, changing it to return [4,5,6]), the output of test.py does not change. This is not unexpected.
However, I'd like changes to test2.py to be reflected in the output. Is there a way to do this? E.g. something like reparsing test2.py every time test2.getData() is invoked?
Other things tried, from comments:
- Moving import test2into the loop.
- Removing test2.pyc while test is running (with importin and out of loop).
 
    