I want to make a variable global to more than 2 files so that operating in any file reflects in the file containing the variable.
what I am doing is:
b.py
import a
x = 0
def func1():
global x
x = 1
if __name__ == "__main__":
print x
func1()
print x
a.func2()
print x
a.py
import b
def func2():
print b.x
b.x = 2
I have searched for threads here and find from a import *
is making copies and import a
is otherwise. I expect the code above to print 0 1 1 2
(sure it should be in new lines) when execute python b.py
but it's showing 0 1 0 1
How does one implement that?