Two import questions in Python 3.0

Kay Schluehr kay.schluehr at
Sat Jan 24 08:24:15 CET 2009

1. I'd expected that absolute imports are used in Python 3.0 by
default. I may be wrong. I've written two versions of a module
print ("import from")
print ("import from")

The first is placed in the lib directory that is globally visible by
means of PYTHONPATH. The second one is placed in a package


The package also contains a module defined by
import sucks

Running A yields "import from" which means unconditional
relative import. It shadows the globally visible module. I've
expected it the other way round.

2. This is kind of a change request.

In a former life I used to call test-scripts as test-scripts. The dumb
idea was to point e.g. to
lib/tests and run

    test_nodeclasses (__main__.AST_Tests) ... ok
    test_parse (__main__.ASTHelpers_Test) ... ok

    Ran 12 tests in 0.219s


The new style is implemented rather in lib2to3. If I point to lib/
lib2to3/tests and run

    Traceback (most recent call last):
    File "", line 12, in <module>
       from . import support
    ValueError: Attempted relative import in non-package

The standard error of the years to come that makes working with Python
harder and reminds me that it is not a scripting language anymore
because you can't run anything as a script not even a test.

For pedagogical reasons the behavior of and other standard
library tests shall show uniform behavior when called from the command
line i.e. they shall all fail with this import error message. What do
you think?

More information about the Python-list mailing list