Better error message on recursive import

Thomas Guettler hv at tbz-pariv.de
Fri Sep 12 03:47:42 EDT 2008


Hi,

> Can you give an example of such a recursive import you want the special 
> exception be raised?

===> cat one.py
from two import testtwo
def testone():
     print "one"

===> cat two.py
import one
def testtwo():
     print "two"

===> python one.py
Traceback (most recent call last):
   File "one.py", line 1, in <module>
     from two import testtwo
   File "/mnt/home/tguettler/tmp/rec/two.py", line 1, in <module>
     import one
   File "/mnt/home/tguettler/tmp/rec/one.py", line 1, in <module>
     from two import testtwo
ImportError: cannot import name testtwo


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de



More information about the Python-list mailing list