I had read two other question about it. this
But i dount understand this behavior:
#mod1 __init__.py
g = 5
#mod2 __init__.py
from mod1 import g
def bar():
print g
#main1.py
import mod1
mod1.g = 10
from mod2 import bar
bar() # prints 10
#main2.py
from mod1 import g
g = 10
from mod2 import bar
bar()
So question is why main1 prints 10 and main2 prints 5? What is the real difference between from import and import?