Thanks, didn't realize it would be quite so easy.
- Original Message -
From: "Matt Nordhoff" <[EMAIL PROTECTED]>
To: "ron.longo" <[EMAIL PROTECTED]>
Cc:
Sent: Tuesday, December 11, 2007 2:50 PM
Subject: Re: finding dir of main .py file
>
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]>
On Dec 12, 6:50 am, Matt Nordhoff <[EMAIL PROTECTED]> wrote:
> ron.longo wrote:
> > Nope, maybe I'm not explaining myself well.
>
> > When I do os.getenv('HOME') I get back None.
>
> > According to the docs, 'HOME' is the user's home directory on some
> > platforms. Which is not what I want.
>
> >
ron.longo wrote:
> Nope, maybe I'm not explaining myself well.
>
> When I do os.getenv('HOME') I get back None.
>
> According to the docs, 'HOME' is the user's home directory on some
> platforms. Which is not what I want.
>
> What I want is the directory in which an application's main .py file
st 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
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 t
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
>
subdirectories with stuff that it
needs such as plugins, configuration files, workspaces, etc.
Thanks for the help.
Ron
--
View this message in context:
http://www.nabble.com/finding-dir-of-main-.py-file-tp14277145p14277145.html
Sent from the Python - python-list mailing list archive at Nabble