How to get path of a .py script
P_spam_ at draigBrady.com
P_spam_ at draigBrady.com
Wed Dec 11 07:19:25 EST 2002
Devrim Erdem wrote:
> Hi,
>
> On linux I have a script runSomething.py, the script is sometimes
> executed from a link on the desktop or from another dir.
>
> How can I get the path of the script file itself so that I can locate
> files which are relative to the script file ?
How about: os.dirname(os.path.realpath(sys.argv[0]))+"/myfile"
Pádraig.
More information about the Python-list
mailing list