More elegant way to cwd?
klachemin at comcast.net
Fri Dec 24 20:33:00 CET 2004
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)
pathname = os.path.abspath(pathname)
s = os.path.realpath('..')
s = os.path.join(s, 'Shared')
Thanks for any enhancements you can suggest!
More information about the Python-list