Feed on
Posts
Comments

when you execute a program in python, the program’s name can be found with the following command: 

import sys 

print sys.argv[0]

 to get the full path to the program, use the abspath command: 

import os 

os.path.abspath(sys.argv[0])

 


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

2 Responses to “get a file or program’s full path in python”

  1. on 30 Jun 2010 at 3:55 pm Macia

    Thanks.

  2. on 26 May 2011 at 1:40 am Pin

    Thanx a lot. It is just what was looking for. :)

Did I get this wrong? Let me know!

Trackback URI | Comments RSS