package import

Steve Holden steve at holdenweb.com
Tue Feb 5 23:52:56 EST 2008


Sean Allen wrote:
> ok, what am i doing wrong?
> 
> in current working directory i have:
> 
> t.py
> sub/t1.py
> 
> t.py is:
> 
> import sub.t1
> 
> i get:
> 
> ImportError: No module named sub.t1
> 
> t.py is
> 
> import sub
> 
> i get:
> 
> ImportError: No module named sub.t1
> 
> --
> 
> i am obviously missing something really basic here.
> have tried on multiple machines, linux and mac os x.
> 
Create an empty sub/__init__.py - then Python will recognize sub is a 
package, and allow you to import modules from within it.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list