[Python-Dev] Excluding the current path from module search path?

Chris Withers chris at simplistix.co.uk
Mon Aug 31 14:17:12 CEST 2009

Nick Coghlan wrote:
> Ah, OK - I see the problem now. However, I think the current behaviour
> is correct, it just needs to be documented better (probably noted in
> both the command line doco 

Not sure what you mean by this?

> regarding sys.path manipulation and in the
> doco for site.py).

Agreed :-)

> The reason I think the current behaviour is correct is that site.py and
> sitecustomize.py are meant to be about customising the *site* (i.e. the
> installation of Python that is being executed) rather than about
> customizing a particular application.

Unless you use virtualenv as Guido suggested in the other thread ;-)

> Importing them before the script
> specific directories are prepended to sys.path goes a long way towards
> achieving that.

If sitecustomize.py had more uses that the setdefaultencoding hack, I'd 
argue more about this... If it does have other uses, my argument would 
be that "site" wide is a very subjective term tht many people, myself 
included, would like to be able to mean "per project, I don't *ever* 
want to screw with my actual Python install, it should stay pristine"...

> Also, as was pointed out on the tracker item, having a script that can
> automatically be executed when running an arbitrary Python script
> without any request from or notification to the user is not a good idea
> from a security standpoint.

Agreed, but I think that's only an issue when you're starting up an 
interpreter. If you're running a script from a file or module, I'd say 
it's more akin to what's specified in PYTHONSTARTUP being executed that 
than a random script being silently executed without your permission.



Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk

More information about the Python-Dev mailing list