Finding where to store application data portably

Tony Houghton at
Fri Sep 23 01:50:42 CEST 2005

In <iACYe.103232$4i6.29494 at>,
Ron Adam <rrr at> wrote:

> Tony Houghton wrote:
>>  > This works on Win XP.  Not sure if it will work on Linux.
>>  >
>>  > import os
>>  >
>>  > parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0]
>>  > file = parent + os.sep + '.bombz'
>> Ooh, no, I don't want saved data to go in the installation directory. In
>> general that practice encourages people to run with Admin access, and
>> it's about time Windows users were discouraged from that.
> Yes, it occurred to me you didn't want to do that after I posted.
> Looks like maybe the correct place would be as you suggested, but maybe 
> doing it this way would be better.
> import os
> user = os.path.join( os.environ["USERPROFILE"],
>                       'Application Data',
>                       'Bombz' )

I like that, it's nice and simple. It doesn't look like it's supported
on Win 9x though, but on 9x using the installation directory would be

The address in the Reply-To is genuine and should not be edited.
See <> for more reliable contact addresses.

More information about the Python-list mailing list