On Mon, 23 Nov 2009 12:02:36 -0500, John Guenther wrote:

> This is Mac related. I am running snow leopard. I am using Python 2.6.3.
> 
> I had a lot of difficulty figuring out how to add a directory to
> sys.path that would be there every time I launched Idle.
[...]

For a comprehensive discussion of how to modify sys.path, see 

http://docs.python.org/install/index.html#modifying-python-s-search-path

If you really just need to modify sys.path for one particular user, what 
I would do is add the line

export PYTHONSTARTUP="/home/my_user/python/startup.py"

to my .bashrc.  Then, in the file /home/my_user/python/startup.py, 
include the following code:

import sys

sys.path.append ("/home/my_user/some_dir")

This will add the directory /home/my_user/some_dir to sys.path every time 
you start up Python.  

The reason I like using PYTHONSTARTUP is that you can do other sorts of 
customizations in that file, as well.  For example, I hate not having any 
way to clear the screen when I'm typing at the Python prompt, so I added 
this code to my $PYTHONSTARTUP file:

import os

def clear():
    os.system ('clear')

Hope that all helps!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to