Path ... where is my application's home dir?
Marco Aschwanden
PPNTWIMBXFFC at spammotel.com
Wed Apr 28 10:45:14 EDT 2004
>> I want to store a file in the application directory.
>
> 1) Don't
>
> 2) Why?
- I want to store the current state of the application when leaving the
application in an ini-file.
- It is a "single-user" pc!
- It is Windows.
- I don't like (others would say hate) to use the registry.
- I prefer having ini-files in the application directory.
> 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?
As I said: It is a windows machine, single user, small app... but I am
very glad you made this remarks, cause it reminds me to consider
portability when writing apps - and now I can see, where I am failing.
Thanks.
And yes, the best place to store this information would be in the user's
home dir, but then: Where is it? How to find it under Windows - every
version of windows changes the place for home dirs. It would be nice to
have something like this in a system/version independet way:
sys.users_home_dir
Is there anything like it in Python?
Thanks,
Marco
More information about the Python-list
mailing list