Path ... where is my application's home dir?

Marco Aschwanden PPNTWIMBXFFC at spammotel.com
Wed Apr 28 10:10:39 EDT 2004


On Wed, 28 Apr 2004 10:46:42 -0300, Batista, Facundo 
<FBatista at uniFON.com.ar> wrote:

> [Marco Aschwanden]
>
> #- I want to store a file in the application directory. What is
> #- the easiest
> #- way to figure out, where my application is situated?
>
> You don't need that, just save it without a path and it'll fall in your
> current directory.

No, this is exactly the problem I had: I was opening the file with: 
file('./Text.txt', 'w')
But when you start the application through a windows desktop icon then the 
file will be created on the desktop!

>
> But if you need it for something else:
>
>>>> import os.path
>>>> os.path.curdir
> '.'
>>>> os.path.abspath(os.path.curdir)
> 'C:\\temp'
>
> .	Facundo

To make a day-long-story short: sys.argv[0] is the solution. (I always 
tested the wrong (old) version in which my changes had no effect.

Thanks,
Marco





More information about the Python-list mailing list