REPOST: Re: pth files - can they prepend to sys.path?

Martin von Loewis loewis at
Fri Dec 28 18:59:59 CET 2001

"Skip Montanaro" <skip at> writes:

> Is it possible to force a directory mentioned in a .pth file to be
> inserted at the beginning of sys.path instead of appended to the
> end?

By means of a dirty trick, perhaps. Put a line

import prepend_foo

into a .pth file, then add a module into the same
directory, which reads

import sys

Works from Python 2.1 on.


========= WAS CANCELLED BY =======:
From: Martin von Loewis <loewis at>
Newsgroups: comp.lang.python
Subject: cmsg cancel <j4vgerkyxs.fsf at>
Control: cancel <j4vgerkyxs.fsf at>
Date: Mon, 31 Dec 2001 01:34:01 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.j4vgerkyxs.fsf at>
X-Trace: 1009775172 27193 (31 Dec 2001 05:06:12 GMT)
X-Complaints-To: usenet at
NNTP-Posting-Date: Mon, 31 Dec 2001 05:06:12 +0000 (UTC)
X-No-Archive: yes
X-Unac4ncel: yes
X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999)

This message was cancelled from within Mozilla.

More information about the Python-list mailing list