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
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
resides. That is, when I type:
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
>