relative import broken?

Torsten Bronger bronger at physik.rwth-aachen.de
Thu May 1 01:06:52 EDT 2008


Hallöchen!

Sam 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".

I didn't look it up myself, but maybe a __init__.py file is missing
so that it can be recognised as a package.

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