I'm trying to modify the sys.path in one of my Python files in order to have some specific libraries dirs in the modules search path (it might not be the best way but ...). If I insert several paths in the front of sys.path my script is not taking into account those paths for future imports. If i make a whole new list containing those libraries dirs i need and assign that list to sys.path then those imports are taken into account. Is this the correct behavior? I'm using python 2.5.4. Could it be something from my environment that could lead to such behavior?
Some code snippets:
If I do
pathtoInsert1 = " .... " pathtoInsert2 = " .... " sys.path.insert(0, pathToInsert1) sys.path.insert(0, pathToInsert2)
it does not work. It does not take into account the paths.
If I do
pathList = [pathToInsert1, pathToInsert2] sys.path = pathList
it works.
Thanks