OO Windows Registry API
drtimcouper at yahoo.co.uk
Thu Mar 29 10:11:08 CEST 2001
I would prefer this style of registry access.
1. reg[HKEY_LOCAL_MACHINE]['Software']['My App']
I'd prefer to see:
reg[HKEY_LOCAL_MACHINE]['Software\My App'] or,
perhaps, more Pythonesquely
2. What about a AddKey-type of method:
> After using the _winreg module I was pining for the
> fjords -- oh, sorry -- I was pining for a more
> Pythonesc API. I noticed that the Python
> documentation mentions that a better API may be
> written in the future, but none has been
> forthcoming. So -- while up at 2AM with my
> 6-week-old son last night -- I wrote a wrapper that
> exposes the registry as a dictionary-like object.
> It seems to work really well, and more importantly
> it feels more like a Python module should.
> I decided to search Python-Dev for mentions of a
> higher-level API and found a squabble over various
> proposals. Did the idea of an OO interface die last
> August, or is there any interest in what I've done?
> (Untested) Example code:
> from winreg import Registry, NewKey,
> reg = Registry()
> # Create a new "My App" key under
> reg[HKEY_CURRENT_USER]['Software']['My App'] =
> # Add some values to the newly created key.
> # Note: the module only supports strings right now,
> but that's
> # easy to change.
> reg[HKEY_CURRENT_USER]['Software']['My App']['foo']
> = 'value 1'
> reg[HKEY_CURRENT_USER]['Software']['My App']['bar']
> = 'value 2'
> # Create a new subkey.
> App']['subkey'] = NewKey()
> # Delete a value.
> del reg[HKEY_CURRENT_USER]['Software']['My
> # Delete a key.
> del reg[HKEY_CURRENT_USER]['Software']['My App']
> Any comments or suggestions? If anyone is
> interested in the code, I'll post it on the web.
> Benji York
> york at ficom.net
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie
More information about the Python-list