.pth files?

Bengt Richter bokr at oz.net
Wed Mar 23 06:52:53 CET 2005


On 22 Mar 2005 09:29:39 -0800, "insyte at gmail.com" <insyte at gmail.com> wrote:

>I'm unclear on how .pth files work.  Some posts imply they can be
>arbitrarily named, as long as they include the .pth extension, and can
>exist anywhere in the current sys.path.  Other documentation seems to
>imply that they must be named <package>.pth, although I'm not sure what
>"package" it would be named after.
>
>I used strace to see if I could see which files it was looking for, but
>the output didn't show a single attempted stat() or open() of any .pth
>files.
>
>I may be barking up the wrong tree with the .pth files, anyway.  Is
>there a general "best practice" for appending additional directories to
>search for modules?  Specifically, I frequently write utilities that
>depend on a shared module or two that I don't particularly want to
>stick in the "site-packages" directory.  The layout I generally prefer
>is a "lib" dir in the same directory as the assorted scripts.  Clearly,
>I could just do a 'sys.path.append["./lib"]', but that seems kludgy.
>
>Any clarifications or recommendations?
>
>Thanks!
>
I haven't looked at all the ("about 23") hits, but have you tried googling for

    pth site:python.org/doc

? The first hit looks promising.

(BTW, for your next python question, try some relevant words in place of "pth" before posting ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list