faqts : Computers : Programming : Languages : Python : Common Problems : Shell Scripts

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 6 people (100%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

Is there a way for the script to get the path of the file it's in?

Nov 2nd, 2004 07:46
Jonathan Schroder, unknown unknown, William Park


What you want are 
    sys.argv[0] 
    os.environ['PWD'] 
    os.getcwd() #tells the working dir, which is by default where the 
script is located