Problem with Packages

Srikanth sri1025 at gmail.com
Thu Mar 8 03:26:45 EST 2007


> It appears that you forgot the basic rule: a package is a directory with
> an __init__.py file (even if empty).

Exactly right. I didn't know that __init__.py is a mandatory one.
Thanks for pointing out.

> > my_apps
> > |
> > |--> mod3.py
> > |--> dir1/dir1_1/mod1.py
> > |--> dir2/dir2_2/mod2.py
>
> You need 4 of such files here.

Thanks again for saying 4, cause I would have definetly put only 2
(inside dir1_1 and dir2_2)

> > And the directory my_apps is included in PYTHONPATH environment
> > variable, what am I doing wrong? I executed this code under PyDev and
> > it's working perfectly but when I run it outside of PyDev, it fails.
>
> Maybe PyDev plays some tricks with PYTHONPATH or something...
>

I got the same doubt and I checked PyDev before posting, the
PYTHONPATH is exactly the same but I didn't notice or rather
overlooked __init__.py file it created automatically when I created
packages using the dialogs.

> Gabriel Genellina

Thanks you Gabriel!
-- Srikanth




More information about the Python-list mailing list