pth files - can they prepend to sys.path?

Martin von Loewis loewis at
Fri Dec 28 12:59:59 EST 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.


More information about the Python-list mailing list