[Python-Dev] Relative imports in Py3k (original) (raw)

anatoly techtonik techtonik at gmail.com
Sat Sep 25 15:15:12 CEST 2010


Hi,

I wonder if situation with relative imports in packages is improved in Python 3k or we are still doomed to a chain of hacks?

My user story: I am currently debugging project, which consists of many modules in one package. Each module has tests or other useful stuff for debug in its main section, but it is a disaster to use it, because I can't just execute the module file and expect it to find relatives. All imports are like:

from spyderlib.config import get_icon from spyderlib.utils.qthelpers import translate, add_actions, create_action

PEP 328 http://www.python.org/dev/peps/pep-0328/ proposes:

from ... import config from ..utils.qthelpers import translate, add_actions, create_action

But this doesn't work, and I couldn't find any short user level explanation why it is not possible to make this work at least in Py3k without additional magic.

-- anatoly t.



More information about the Python-Dev mailing list