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

Grant Edwards grante at visi.com
Wed Apr 28 10:13:30 EDT 2004


On 2004-04-28, Marco Aschwanden <PPNTWIMBXFFC at spammotel.com> wrote:

> I want to store a file in the application directory.

1) Don't

2) Why?

> What is the easiest way to figure out, where my application is situated?

3) Under Unix in general there is no reliable, portable way to
   do that.

> sys.argv[0] does not work for my purposes... do you have any
> other ideas.

Yes.

It sounds like you're trying to do a bad thing in the Unix
world.  Firstly, some smart admins have entire filesystems
mounted read-only.  Your application may live in one of those.

Secondly, global configuration files go in /etc.  Per-user
configuration files go in the user's home directory in
.<appname>-conf .<appname>rc or under the .<appname>/
directory.  If you want them preserved across reboots, then
caches of stuff go in /var/cache/<appname>.  Files that don't
need to survive a reboot go in /tmp.

What are you trying to do?

-- 
Grant Edwards                   grante             Yow!  After THIS, let's go
                                  at               to PHILADELPHIA and have
                               visi.com            TRIPLETS!!



More information about the Python-list mailing list