The module importing seems failing when cross-importing.
My prog.py
file:
import sys
sys.path.append(".")
from m1 import f1
And m1.py
:
from m2 import f2
def f1():
pass
And m2.py
:
from m1 import f1
def f2():
pass
My module m1 needs to use some functions in module 2, and module 2 needs to use some functions in module 1, so I import them the way above. But Python (python3) doesn't let me do so. Here's the exeption:
Traceback (most recent call last):
File "prog.py", line 3, in <module>
from m1 import f1
File "/temp/m1.py", line 1, in <module>
from m2 import f2
File "/temp/m2.py", line 1, in <module>
from m1 import f1
ImportError: cannot import name 'f1'
I know it is cross-importing, but how to solve this problem?