This will add the path to your Python process / instance (i.e. the executable executable). The path will not be changed for any other Python processes. Another working Python program will not change its path, and if you exit your program and run it again, the path will not include what you added earlier. What you do is usually correct.
set.py:
import sys sys.path.append("/tmp/TEST")
loop.py
import sys import time while True: print sys.path time.sleep(1)
run: python loop.py &
This will start loop.py connected to your STDOUT and it will continue to run in the background. Then you can run python set.py Each of them has a different set of environment variables. Note that the output from loop.py does not change, since set.py does not change the environment of loop.py
Import Note
Python imports are dynamic, like the rest of the language. Static communication does not occur. Import is an executable line, like sys.path.append...
Joe Feb 27 '13 at 10:24 2013-02-27 10:24
source share