absolute imports (python-2.5)

jUrner at arcor.de jUrner at arcor.de
Tue Aug 29 09:51:56 EDT 2006


Hello all

I just played around a bit with python 2.5 and relative imports.
Bit disappointed so far. Hoped to be able to use this new feature
to develop standalone libraries that can be just dropped into
any project without having to adjust any imports.

pkg/
pkg/__init__.py
pkg/main.py
pkg/string.py


"main.py" does:
from . import string

no problem if you import the whole package from another module:
import pkg

but if you execute "main.py" you get an error
"ValueError: Relative importpath too deep"

This is looks a nightmare come true for developing modules.
I read all available information regarding the "-m" switch and its
limitations when it comes to relative imports. Being impatient
and scarend of having to wait another (year!) for this feature to
become usable I wonder if anyone has any better information on
things ahead.

Juergen




More information about the Python-list mailing list