Shane Geiger <[EMAIL PROTECTED]> writes: > Some usage of __file__ will always get what you want in various situations: > > print __file__ > > print modulename.__file__ > > print os.getcwd() + "/" + __file__ > > > > > > Rick Dooling wrote: >> On Dec 11, 10:08 am, "ron.longo" <[EMAIL PROTECTED]> wrote: >> >>> Is there any way that I can find the path of the main .py file of my >>> application? >>> >>> For example, I have an application with some resources which are in a >>> subdirectory: >>> >>> myPythonApp.py >>> /resources >>> image1 >>> image2 >>> etc. >>>
The following two versions are working for me: import os, sys print os.path.abspath(os.path.dirname(sys.argv[0])) print os.path.abspath(os.path.dirname(__file__)) Stefan. -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list