View Single Post
  #5   (View Single Post)  
Old 31st March 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

Well, there might be a better way Carpetsmoker but this comes to mind:

since you obviously have access to the winreg object within the function, and just need to know the key and other arguments: why not pass the key as a string and use eval() to access the corresponding attribute/method through it. Since it appears to be the data structure you want to use to access it by, lol.

example:

Code:
>>> class Klass:
...     name = "I am called Klass"
... 
>>> k=Klass()
>>> def test(regkey, key, value):
...   print( eval("k.%s" % str(regkey)) )
... 
>>> test('name', 'and', 'others')
I am called Klass
>>>
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.

Last edited by TerryP; 31st March 2009 at 10:27 PM.
Reply With Quote