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



More information about the Python-list mailing list