How to import a package

Mike Dean klaatu at evertek.net
Fri Dec 6 23:48:36 EST 2002


On Sat, 07 Dec 2002 16:06:15 +1300 sashan <sashang at nospam.ihug.co.nz> wrote:
> I thought doing this:
> sys.path.append('e:/code/AppDir/SomePackage')

> would have the same effect as setting PYTHONPATH to
> <long list of previous directories>;e:/code/AppDir/SomePackage

Yes, it does.  But, for the file structure you gave, you want:

sys.path.append('e:/code/AppDir')

If SomePackage is a subdirectory of any directory in your sys.path, and in
SomePackage is a file __init__.py, then SomePackage is a package.  So
you always want a package's parent directory in sys.path, not the
package directory itself.

HTH,
Mike

-- 
"ERROR 155 - You can't do that."
                -- From the Data General S200 Fortran error code list.



More information about the Python-list mailing list