Python import search path

Kevin Zhang kevin.misc.10 at gmail.com
Sat Aug 20 05:52:27 EDT 2011


Hi,

This is the directory tree.
project
└── sme
    ├── src
    │   ├── a.pth
    │   ├── sss.py
    └── test
        └── ttt.py

I need to import sss.py in ttt.py.

Found a few solution in python docs.
A. sys.path.append
B. add ***.pth file
C. edit .../site-packages/site.py

I found out that a.pth only works when in directory like
/usr/lib/pythonX.Y/site-packages
instead of in current directory.

I think A is not so pretty, and I don't have root  privilege to use B and C.
So any both more elegant and practical solutions?
Thanks.

Kevin Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110820/d1b17d1e/attachment.html>


More information about the Python-list mailing list