lorien lorien tmp relimport find tmp relimport tmp relimport tmp relim

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
lorien@lorien /tmp/relimport/a/b $ find /tmp/relimport
/tmp/relimport
/tmp/relimport/__init__.py
/tmp/relimport/a
/tmp/relimport/a/__init__.py
/tmp/relimport/a/foo.py
/tmp/relimport/a/b
/tmp/relimport/a/b/__init__.py
/tmp/relimport/a/b/test.py
lorien@lorien /tmp/relimport/a/b $ cat test.py
from ..a import foo
lorien@lorien /tmp/relimport/a/b $ python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from ..a import foo
ValueError: Attempted relative import in non-package