In b.py, you are setting b.py's myvar. You want to access a's value of myvar. So b.py might look like:
import a
import c
a.myvar = 'b' # belongs to a
myvar = 'something different' # belongs to b
c.pr()
And you need to update c.py so that it uses a.py's myvar, not it's own local copy. So c.py:
import a
def pr():
print a.myvar
Why?
In your original c.py, when you call from a import myvar
, this is equivalent to:
import a
myvar = a.myvar
This makes a local version of myvar
in c.py upon import. If this is confusing, I found this article about how python variables work very informative.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…