In file1.py:
def test1():
print "hi"
In file2.py:
from file1 import test1
def test2():
print "hello"
test1()
test2()
Output:
hi
hello
Now in file 1 if i include test2 i get the following error:
from file2 import test2
def test1():
print "hi"
Traceback (most recent call last):
File "file1.py", line 1, in ?
from file2 import test2
File "/root/pyt/file2.py", line 1, in ?
from file1 import test1
File "/root/pyt/file1.py", line 1, in ?
from file2 import test2
ImportError: cannot import name test2
Can some explain why and how to make it work?