Python at compile - possible to add to PYTHONPATH

Avell Diroll avelldiroll at yahoo.fr
Wed Jun 21 19:30:38 EDT 2006


rh0dium wrote:
(snip)
> I want to add /foo/bar to the PYTHONPATH build so I don't have to add
> it later on.  Is there a way to do this?
(snip)

If i understand correctly, you want to add a directory to your 
PYTHONPATH for a specific script without modifying the system PYTHONPATH 
global variable ...

To import the Gazonk() class defined in /foo/bar/baz.py without adding 
/foo/bar to PYTHONPATH you can try this:

###

import sys
sys.path.append('/foo/bar')

import baz
quux = baz.Gazonk()

###

hope it helped ...



More information about the Python-list mailing list