[Tutor] File like object for Windows registry

Henry Finucane h.finucane at gmail.com
Thu Aug 3 22:54:40 CEST 2006


On 8/3/06, Andre Roberge <andre.roberge at gmail.com> wrote:
> On 8/3/06, Henry Finucane <h.finucane at gmail.com> wrote:
> > On 8/3/06, K.Weinert at gmx.net <K.Weinert at gmx.net> wrote:
> > > Hello!
> > >
> > > My app should run on debian and windows platforms. For storing the configuration data, I use the ConfigParser module.
> > >
> > > What I find difficult is to determine a place for my configuration file. On debian, it is simply
> > >
> > > os.path.join(os.path.expanduser("~")),"myconfig")
>
> This works on Windows as well.  I just tried it :-)

Doh. Always try the simple stuff first :P.

> > >
> > > but what am I supposed to do on Windows? I think a clean solution would be to create a file-like object that reads and writes to the registry, is it?
>
> Messing with the registry is (imo)  a bad idea.
>
> >
> > You might be able to do that, I don't know much about win32
> > programming, but I believe a better solution is to use the built-in
> > windows variables. %APPDATA% is where you should store user-specific
> > application data (and even Microsoft is starting to store XML
> > configuration files there), and it's an easy variable to get.
> >
> > >>> import os
> > >>> os.environ["APPDATA"]
> > 'C:\\Documents and Settings\\UserName\\Application Data'
> >
> > That should function just fine as a home directory replacement.
> >
> ...
>
> André
>


-- 
--H.F.
My penguin is bigger than yours, mister...


More information about the Tutor mailing list