Is there a more elegant way to change the working directory of Python
to the directory of the currently executing script, and add a folder
called 'Shared' to the Python search path?

This is what I have. It seems like it could be shorter, somehow.

# Switch Python to the current directory
import os, sys
pathname, scriptname = os.path.split(sys.argv[0])
pathname = os.path.abspath(pathname)
os.chdir(pathname)
s = os.path.realpath('..')
s = os.path.join(s, 'Shared')
sys.path.append(s)

Thanks for any enhancements you can suggest!

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to