I am having the following 3 Python files:
a.py:
myvar = 1
def increment():
global myvar
myvar += 1
b.py:
import a
a.increment()
print(a.myvar)
c.py:
from a import increment, myvar
increment()
print(myvar)
Now when I run b.py and c.py independently, I get:
python3 ./b.py
2
python3 ./c.py
1
Can you explain the difference?
Thanks!
This is Python 3.7.3 on the latest Debian GNU/Linux (stable).