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

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Dec 28 18:59:59 CET 2001


"Skip Montanaro" <skip at pobox.com> 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 prepend_foo.py into the same
directory, which reads

import sys
sys.path.insert(0,"foo")

Works from Python 2.1 on.

HTH,
Martin

========= WAS CANCELLED BY =======:
Path: news.sol.net!spool1-milwwi.newsops.execpc.com!newsfeeds.sol.net!news-out.visi.com!hermes.visi.com!out.nntp.be!propagator-SanJose!in.nntp.be!news-in-sanjose!news-xfer.nuri.net!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r
From: Martin von Loewis <loewis at informatik.hu-berlin.de>
Newsgroups: comp.lang.python
Subject: cmsg cancel <j4vgerkyxs.fsf at informatik.hu-berlin.de>
Control: cancel <j4vgerkyxs.fsf at informatik.hu-berlin.de>
Date: Mon, 31 Dec 2001 01:34:01 GMT
Organization: A poorly-installed InterNetNews site
Lines: 2
Message-ID: <cancel.j4vgerkyxs.fsf at informatik.hu-berlin.de>
NNTP-Posting-Host: 211.57.49.2
X-Trace: news2.kornet.net 1009775172 27193 211.57.49.2 (31 Dec 2001 05:06:12 GMT)
X-Complaints-To: usenet at news2.kornet.net
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