[Tutor] conventions for establishing and saving default valuesfor variables

Hugo Arts hugo.yoshi at gmail.com
Thu Jun 17 13:13:55 CEST 2010


On Thu, Jun 17, 2010 at 1:19 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Thu, 17 Jun 2010 03:25:03 am Alan Gauld wrote:
>> "R. Alan Monroe" <amonroe at columbus.rr.com> wrote
>>
>> >> directory, I suppose. Under windows, probably the registry.
>> >> There's the _winreg and configparser modules.
>> >
>> > Consider using the %USERPROFILE% environment variable rather than
>> > the
>> > registry.
>>
>> How would that work? That is just a single variable that points
>> to the users Settings folder. Effectively their home directory in
>> unix terms, so you could store the config file there. But
>> you couldn't store the kind of data you would store in the
>> registry?
>>
>> I'm confused.
>
> [snip explanation of environment variables]
>
> So unless I've missed something exceedingly subtle, writing to
> environment variables is not a solution to the problem of saving
> default values. It's not even part of a solution.
>

Just speculation here, but.. I suppose what he's suggesting is that
you use ConfigParser on both linux and windows, rather than the
registry on one platform and a config file on the other. on windows
you'd then place the config file in the %USERPROFILE% directory.

It's actually a rather good idea, not having to bother with the
registry saves you a lot of work.

Hugo


More information about the Tutor mailing list