From my tests, the 2nd print statement indicates that "/test", "/another_test" and "/tmp" are included in sys.path and subsequent imports should load modules located in these directories.
I created a python module, tmpmodule.py in /tmp which simply included a print statment. When running the example above, it printed as expected. If the module couldn't be loaded, an exception would have been raised.
If you are naming your modules with the same name as either a standard lib module or a 3rd party module then sys.path.append() would result in your module never being imported. Using sys.path.insert(...) allows you to place the path anywhere in the search path, such that you can have it take precedence over other modules with the same name. In my case above, sys.path.append() would have worked reasonably well because there is no other tmpmodule.py in my search path.
One caveat, at least when running under mod_python, the above sys.path.insert(...) calls will be inserted each time the spyce page is loaded resulting in redundant entries. So you'll probably want to test for their presence before inserting/appending them, for example:
[[ if '/tmp' not in sys.path: sys.path.append("/tmp") ]]
Hope this helps,
Get latest updates about Open Source Projects, Conferences and News.