[Tutor] python function to know the path of the program in execution

nikunj badjatya nikunjbadjatya at gmail.com
Fri Feb 5 11:08:57 CET 2010


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.
[ ABC at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100205/25f4e345/attachment.htm>


More information about the Tutor mailing list