Re: relative import broken?
- From: Peter Otten <__peter__@xxxxxx>
- Date: Wed, 30 Apr 2008 16:12:17 +0200
test wrote:
basic noob question here.
i am trying to reference a package, i have the structure:
mypack/
__init__.py
test.py
subdir1/
__init__.py
mod1.py
subdir2/
__init__.py
mod2.py
can someone please tell me why the statement:
from mypack.subdir1.mod1 import *
does NOT work from mod2.py nor from test.py?
instead, if i use:
from subdir1.mod1 import *
it works perfectly from test.py.
....?
The parent directory of mypack must be in the module search path, see
http://docs.python.org/tut/node8.html#l2h-19
The least intrusive way to achieve this is to move test.py one level up in
the directory hierarchy.
Peter
.
- References:
- relative import broken?
- From: test
- relative import broken?
- Prev by Date: I messed up my wxPython install (Eclipse Configuration Issue)
- Next by Date: Re: Tremendous slowdown due to garbage collection
- Previous by thread: relative import broken?
- Next by thread: I messed up my wxPython install (Eclipse Configuration Issue)
- Index(es):
Relevant Pages
|