relative import broken?
Torsten Bronger
bronger at physik.rwth-aachen.de
Thu May 1 01:12:41 EDT 2008
Hallöchen!
Sam writes:
> On Apr 30, 9:11 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:
>> Sam <landofdre... at gmail.com> writes:
>> > I also have a problem with relative import; I can't for the life of me
>> > figure out how to use the damn thing. I think the main problem is with
>> > getting Python to recognize the existence of a package. I have
>>
>> > S/
>> > p.py
>> > B/
>> > b.py
>> > W/
>> > pyw/
>> > u.py
>> > ws.py
>>
>> > and I'd like to get u.py to import all the other 3 programs. I put
>> > empty __init__.py files in all of the above directories (is this
>> > necessary?), and even manually added the pathway (r'C:\Myname\S') to
>> > sys.path, but when I execute
>>
>> > from S import p
>>
>> > in u.py Python gives "ImportError: No module named S".
>>
>> A silly question: is the directory that contains "S" in PYTHONPATH or
>> in sys.path?
>
> It's in sys.path.
"S" or its parent directory?
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: bronger at jabber.org
(See http://ime.webhop.org for further contact info.)
More information about the Python-list
mailing list