finding dir of main .py file
Rick Dooling
rpdooling at gmail.com
Tue Dec 11 12:25:07 EST 2007
On Dec 11, 10:08 am, "ron.longo" <long... at npt.nuwc.navy.mil> 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
More information about the Python-list
mailing list