Easier way to get the "here" path?
alif016 at gmail.com
Sat Jul 26 18:02:14 CEST 2008
> I have to go into these convulsions to get the directory that the
> script is in whenever I need to use relative paths. I was wondering if
> you guys have a better way:
If you just need the current path (where it is executed) why not use
which returns a string of the absolute path to the module being executed.
$ echo "print __file__" > path.py
In : import path
In : import os
In : os.path.join(os.getcwd(), path.__file__.rstrip("c"))
More information about the Python-list