I have a Python project with multiple .py files. One file should be the "control" file, where parameters can be altered. Other files should receive input from this control file, and return varying outputs.
My code does as expected if I am using a fresh kernel (I am using Spyder in Anaconda), but after one run if I change a parameter in the control file, not all subsequent variables are updated.
I have searched stackoverflow and google but am struggling to find the "right way" to accomplish this. In the real case there are many more files with many more interdependencies, but I have boiled the problem down to the following simple example.
For example, control.py:
var = 42
file.py:
import control.py as con
var2 = con.var
print(var2)
Running file.py the first time prints 42
, as expected. But if within control.py I change to
var = 43
,
save, and then run file.py again, I receive
42
I want file.py to give 43
in this instance.