> However, if I change both imports to be absolute using the > "from/import" form, it doesn't work:: > > module5.py: > from package import module6 # absolute import > > module6.py: > from package import module5 > > Now I get an exception:: > > >>> from package import module5 > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "package/module5.py", line 1, in ? > from package import module6 > File "package/module6.py", line 1, in ? > from package import module5 > ImportError: cannot import name module5 > > Is this behavior expected? Or is it a bug? It's probably due to the extremely subtle (lame?) way that "from package import module" is (has to be?) implemented. It's too late at night for me to dig further to come up with an explanation, but maybe reading the file knee.py is helpful -- it gives the *algorithm* used for package and module import. In 2.2 and before, it's Lib/knee.py; in 2.3, it's been moved to Demo/imputils/knee.py. I think that you'll have to live with it. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4