[SciPy-User] should one put "." into PYTHONPATH

Jason Rennie jrennie at gmail.com
Thu May 5 21:08:15 EDT 2011


On Thu, May 5, 2011 at 7:23 PM, Ondrej Certik <ondrej at certik.cz> wrote:

> is it a good practice to have the following in .bashrc:
>
> export PYTHONPATH=$PYTHONPATH:.
>

My opinion is "no" since import behavior then depends on the directory from
which you run your script.

I know that Ubuntu long time ago had the "." in PYTHONPATH by default,
> and then dropped it. The reason why I want it is so that I can develop
> in the current directory, by doing things like:
>
> python examples/a.py
>

Python does automatically include the script directory in sys.path, so if
you put your scripts at the base of your library hierarchy (or put your
library in your bin/ directory), you won't have to worry about setting
PYTHONPATH.

http://pythonquirks.blogspot.com/2010/07/absolutely-relative-import.html
http://docs.python.org/library/sys.html#sys.path

Cheers,

Jason

-- 
Jason Rennie
Research Scientist/Software Engineer
Google/ITA Software
617-714-2645
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110505/7133484c/attachment.html>


More information about the SciPy-User mailing list