[Tutor] Search path

Jeff Shannon jeff@ccvcorp.com
Wed, 10 Jul 2002 13:06:44 -0700


Michael Montagne wrote:

> I need to add to the python search path a directory that contains my
> personal modules.  This way it will always be safe from upgrading and I
> may easily back it up.  How do I tell python to always include this
> directory in the search path?  Is this even the recommended way to
> handle this issue?  Does it have something to do with .pth files?

Yes.  You create a .pth file, with each line of the file being the name of
a directory.  On startup, Python will parse all the .pth files it finds,
and will add each listed directory to the import search path.

Jeff Shannon
Technician/Programmer
Credit International