For example, I have the following source files:
file a.py
from b import *
def A():
print 'function A'
B()
return
file b.py
from a import *
def B():
print 'function B'
A()
return
def main():
A()
B()
return
if __name__ == '__main__':
main()
Then I run python b.py
, I met with the following error:
NameError: global name 'A' is not defined
The full message, together with prints is as follows:
function A
function B
Traceback (most recent call last):
File "b.py", line 14, in <module>
main()
File "b.py", line 9, in main
A()
File "/home/mypath/a.py", line 5, in A
B()
File "/home/mypath/b.py", line 5, in B
A()
NameError: global name 'A' is not defined
What's wrong with it? Thank you all for helping me!