# code of foo.py
var = 7
#code of foo1.py
import foo
print(foo.var) # it prints 7
foo.var = 9
print(foo.var) # it prints 9
#from "foo" reload(var)
import foo #reimporting module
print(foo.var) # still it prints 9 instead of 7 why?
# code of foo.py
var = 7
#code of foo1.py
import foo
print(foo.var) # it prints 7
foo.var = 9
print(foo.var) # it prints 9
#from "foo" reload(var)
import foo #reimporting module
print(foo.var) # still it prints 9 instead of 7 why?
The reason is that second import foo
doesn't effect. See this question: What happens when a module is imported twice?.
In python modules are singleton, meaning every import statement return the same instance of a module. As a consequence, any mutation of a module is visible to every scope that import this module.
https://docs.python.org/3/tutorial/modules.html#more-on-modules