creating package question

infidel saint.infidel at
Wed Nov 16 20:59:34 CET 2005

erick_bod... at wrote:
> I think I have an answer to my own question.  In the
> WindowsComponents/ file, I have the following, that feels
> like a better answer for the problem.  Is there a better answer than
> this?
> import os, sys
> sys.path.append(os.path.join(os.getcwd(), 'Common'))

My solution to this is to use a .pth file.  In my site-packages folder
under the python installation, I have a file named infidel.pth.  This
file contains the path to the folder where I put all my python source
code (C:\src\py).  In your case, you could have the path to your 'root'

One of my projects is structured like this:


Now the controllers package can do imports like this:

from infidel.models import basemodel
from infidel.views import baseview

The point is that the .pth file in site-packages adds custom paths to
your sys.path

More information about the Python-list mailing list