relative import broken?

Alan Isaac aisaac at american.edu
Sat Apr 28 14:58:30 EDT 2007


Are relative imports broken in 2.5?
Directory ``temp`` contains::

        __init__.py
        test1.py
        test2.py

File contents:
__init__.py and test2.py are empty
test1.py contains a single line::

        from . import test2

Python 2.5.1 under Win2000, cmd line execution,
produces as output::

        Traceback (most recent call last):
          File "F:\temp\test1.py", line 1, in <module>
            from . import test2
        ValueError: Attempted relative import in non-package

Why?

Thanks,
Alan Isaac





More information about the Python-list mailing list