I've following use case:
a.py:
import b
import c
c.fun()
b.py:
def fun():
print 'b'
c.py:
def fun():
b.fun()
python a.py
doesn't work. It fails with NameError: global name 'b' is not defined
.
My understanding of import in python was that a name is added in sys.modules
. If that is the case then c.py
should also see module b
. But apparently that is not the case. So can anyone explain what exactly happens when a module is imported.
Thanks.