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.
>>
>
> I just put the reference in my module. Don't hard code an absolute
> path, use the environment tools.
>
> app_path = os.getenv('HOME') + "/your_sub_dir"
>
> resources_path = os.getenv('HOME') + "/your_sub_dir/resources"
>
> If there's another way, someone else will jump in.
>
> rd
>
--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED] | 402-438-8958 | http://www.ncee.net
Leading the Campaign for Economic and Financial Literacy
--
http://mail.python.org/mailman/listinfo/python-list