I have some modules in one directory path that I want to import into the python shell while in another path. I set the PYTHONPATH variable in the shell
c:\Users\me\Documents> set PYTHONPATH="C:\Users\me\Documents\sandbox\puzzler3\build\lib"
c:\Users\me\Documents> set | grep PYTHONPATH
PYTHONPATH="C:\Users\me\Documents\sandbox\puzzler3\build\lib"
From the default directory \Users\me\Documents\poly, I do the following
poly> python
>>> import sys
sys.path
Instead of seeing the PYTHONPATH path in the list, I see a mangled concatenation of the current default path with PYTHONPATH. Changing to a different default directory gives the same results but with the new directory path.
'c:\\Users\\me\\Documents\\poly\\"C:\\Users\\me\\Documents\\sandbox\\puzzler3\\build\\lib"'
Naturally, trying to import modules from the desired location fails. Unsetting PYTHONPATH, restarting python, and printing out sys.path shows a list without the current default directory.
Why is python performing this concatenation instead of simply including the contents of PYTHONPATH as an element is sys.path?