How do I get the current path of my python file that is currently running.

rasmus matt.rasmus at
Thu Aug 23 17:06:38 CEST 2007

On Aug 23, 3:33 am, Arnau Sanchez <ar... at> wrote:
> Lamonte Harris escribió:
> > Say I start i click on a python file on my desktop, how could I return
> > the path of the current python file thats running?

Try this:

import sys
import os
print sys.argv[0]
print os.getcwd()

sys.argv[0] should contain the name of the script as it was called.
os.getcwd() will return the current working directory, which may also
find helpful.

hope this helps.


More information about the Python-list mailing list