Get Path of current Script
eryksun ()
eryksun at gmail.com
Mon Mar 14 07:23:59 EDT 2011
On Monday, March 14, 2011 5:53:25 AM UTC-4, Alain Ketterlin wrote:
> sys.path[0] is the path to the directory containing the script that the
> interpreter started with.
How about os.path.dirname(os.path.realpath(sys.argv[0]))? I think realpath is required in case someone runs it from a symlink. I don't know what can be done about Windows symlinks created with mklink. Thankfully that's uncommon.
More information about the Python-list
mailing list