[Python-Dev] Order that site-packages is added to sys.path (original) (raw)

Martin v. Loewis martin@v.loewis.de
12 Feb 2002 10:39:44 +0100


barry@zope.com (Barry A. Warsaw) writes:

So the question is: why does site.py append site-packages instead of prepending it to sys.path?

I think the rationale was that you are precisely not supposed to override any of the standard modules. It was considered a good thing that if you do "import string" in some version of Python, you know exactly what you will get.

There is currently one exception to that rule, which is the xml module and PyXML: the standard xml module allows being replaced by add-on (later, better) packages. However, there have been complaints that this is so: One of Paul Prescod's applications would break if PyXML was installed, since PyXML performed some stricter argument checking in certain cases.

The same problem would occur more frequently if you have site-packages in front of the path: The add-on package may behave worse than the standard package in some cases (especially after installing a Python bugfix release); this problem is hard to track.

In the specific case, I'd propose the following strategy:

Regards, Martin