[Python-Dev] Fixing #7175: a standard location for Python config files
Paul Moore
p.f.moore at gmail.com
Thu Aug 12 14:39:07 CEST 2010
On 12 August 2010 12:59, Tim Golden <mail at timgolden.me.uk> wrote:
> re: using the Registry: To be honest, I was answering the literal
> question posed by Eric: where to put config files? Not the wider
> question: how should config data be stored? Where the answer to
> the latter question might be: the Registry -- much as I find it
> awkward to work with at times.
>
> One very definite point in its favour as regards this discussion
> is that Python on Windows *already* defines a key in the Registry
> (and has done so since v2.0 at least) and it would make some sense
> to place things under there.
>
> Ultimately, I don't feel very strongly about this subject. I'm more
> concerned that the chosen location (file or registry or whatever) be
> documented -- and documented from a Windows perspective as well, so
> you don't have to guess what "HOME" means in this context.
One potential solution would be to use something like
os.path.expanduser("~/.python"), where os.path.expanduser has a
defined behaviour on Windows (one that could do with a little
clarification, yes I know, doc patch welcomed...), but also add an
additional option, that os.path.expanduser will first look in the
registry for the value HKLM\Software\Python\PythonCore\HOME and use
that if present. Then users could set their own interpretation, in a
Windows-standard manner.
If that would be an acceptable option, I could supply a patch to
os.path.expanduser. I will do a clarifying doc patch regardless.
Paul.
PS We could also support ~user by looking in HKEY_USERS\<user
SID>\Software\Python\... but that's probably YAGNI :-)
More information about the Python-Dev
mailing list