This question may have a simple answer. I have a near-trivial module0.py:
a = 1
b = a + 3
I import this module into a script and redefine module0's global constant a:
import module0 as m0
m0.a = 2
print(m0.b)
However, when I run this code, it prints 4 rather than 5. Is there a way to import module0 and change the value of m0.a so that all variables such as m0.b in the global namespace of the imported module are (in some sense) automatically updated with the new value of m0.a?
set_dependent_global_vars()to module0.py which defines and declares as global all variables likeb. Then I call this function immediately afterm0.a = 2in the script and everything works as hoped.