How do I get the current path of my python file that is currently running.
rasmus
matt.rasmus at gmail.com
Thu Aug 23 11:06:38 EDT 2007
On Aug 23, 3:33 am, Arnau Sanchez <ar... at ehas.org> 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?
>
> http://docs.python.org/lib/module-sys.html
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.
Matt
More information about the Python-list
mailing list