[Tutor] HOWTO: adding to sys.path the simplest way.
ricaraoz at gmail.com
Fri Aug 24 16:06:03 CEST 2007
Tim Johnson wrote:
> I have a seperate library directory both on my work station on
> the the remote servers that I write applications for..
> I commonly use sys.path.append('/path/to/mylibraries') in my
> python code.
> That code has to be placed in any standalone script that I write.
> I can also place that path in a system file. On my kubuntu
> workstation, it is /var/lib/python-support/python2.5/.path
> I believe that path is different on the solaris or redhat servers
> that I provide scripts to. Furthermore, any update of the python version
> will necessitate editing of the new .path file.
> I would welcome some opinions on this matter.
> Tutor maillist - Tutor at python.org
You might put your libraries in your development directory :
Then inside /path/devel/myapplications/mynewapplication/myprogram.py
when you want to access a module you just write :
from mylibraries.mygeneralmodule import x
from mylibraries.graphiclibraries.mygraphiclibrary import x
from mylibraries.databaselibraries.mygraphiclibrary import x
Of course /path/devel must be in your path, but as long as the rest of
the structure remains unchanged you may place your stuff anywhere.
More information about the Tutor