sys.path.append(".") OK to do?

Gerhard Häring gh at ghaering.de
Sun May 4 17:29:42 EDT 2003


Robert Oschler wrote:
> I frequently append the current path "." to sys.path when I am working on a
> project, so that files in the local project directory can be found easily by
> "import". 

The directory in which lies the script you execute is put in sys.path, 
anyway. Why would you explicitely need to put the "current directory", 
i. e. "." in sys.path?

> Is there any liabilities to this approach?

Under certain circumstances, it can be a security problem. "." may well 
be something world-writable like /tmp. Now if you even prepend "." to 
sys.path instead of appending it, you've got a real problem.

-- Gerhard





More information about the Python-list mailing list