--- On Fri, 2/5/10, nikunj badjatya <nikunjbadja...@gmail.com> wrote:

From: nikunj badjatya <nikunjbadja...@gmail.com>
Subject: [Tutor] python function to know the path of the program in execution
To: tutor@python.org
Date: Friday, February 5, 2010, 5:08 AM

Hi ,
Is there any python function to know the path of the python program under 
execution.?
If someone executes a program , he should come to know the path of the 
program..!!
ex. suppose a user ABC is running prog.py which is in ~ directory, the user 
currently is in XYZ directory. 


[ a...@localhost XYZ ]$ python ~/prog.py         
The program's location is ~/prog.py

This should be the outcome of the program.

I tried with os.getcwd()
os.getcwd() will return /path/to/folder/XYZ.



Any suggestions?
 
Thanks,
Nikunj Badjatya
Bangalore, India


-----Inline Attachment Follows-----

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


I think this is what you want:

>>> import sys
>>> sys.argv[0]
'C:\\Python26\\testingscripts\\lowdir.py'
>>> 

David



      
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to