problem in appending a path to sys.path

rabbits77 rabbits77.nospam at bigmailbox.net
Wed Feb 25 02:09:46 EST 2004


>>>>sys.path.append(r'D:\Python23\Lib\site-packages\code')
>>>>sys.path
> 
> ['D:\\PYTHON23', 'D:\\PYTHON23\\Lib\\idlelib',
> 'D:\\WINNT\\system32\\python23.zip',
> 'D:\\PYTHON23\\lib\\site-packages\\Pythonwin',
> 'D:\\PYTHON23\\lib\\site-packages\\win32',
> 'D:\\PYTHON23\\lib\\site-packages\\win32\\lib',
> 'D:\\PYTHON23\\lib\\site-packages', 'D:\\Python23\\DLLs',
> 'D:\\Python23\\lib', 'D:\\Python23\\lib\\plat-win',
> 'D:\\Python23\\lib\\lib-tk', 'D:\\Python23',
> 'D:\\Python23\\Lib\\site-packages\\code']
> 
> But when I close the shell and now again open it & do sys.path , it
> doesnt show the path I last appended. i.e
> 
> 
>>>>import sys
>>>>sys.path
> 
> ['D:\\PYTHON23', 'D:\\PYTHON23\\Lib\\idlelib',
> 'D:\\WINNT\\system32\\python23.zip',
> 'D:\\PYTHON23\\lib\\site-packages\\Pythonwin',
> 'D:\\PYTHON23\\lib\\site-packages\\win32',
> 'D:\\PYTHON23\\lib\\site-packages\\win32\\lib',
> 'D:\\PYTHON23\\lib\\site-packages', 'D:\\Python23\\DLLs',
> 'D:\\Python23\\lib', 'D:\\Python23\\lib\\plat-win',
> 'D:\\Python23\\lib\\lib-tk', 'D:\\Python23']
> 
> What am I doing wrong here??
sys.path changed for the same reason why if you set
a="puke"
in the interpreter and then closed the shell and restarted the 
interpreter, the variable a would have no value!!
You are not making a permanent change to sys.path using sys.append!!
I think you really want to modify the PYTHONPATH environment variable, 
I'd guess.




More information about the Python-list mailing list