_winreg newbie question

Joe Green the_3_project at yahoo.com
Tue Apr 29 07:56:31 CEST 2003


I'm having trouble understanding why _winreg.OpenRegistry() does not
want to open the registry in a class.

An example is something like


from _winreg import *

s = 'HKEY_LOCAL_MACHINE'

if (s is 'HKEY_LOCAL_MACHINE'):
  reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
else:
  print "Somehow that didn't work"

That seems to work fine. But when it's inside a class


class myclass:

  def __init__(self, key, cname=None):
    if (cname is 'HKEY_LOCAL_MACHINE'):
      self.reg = ConnectRegistry(cname, HKEY_LOCAL_MACHINE)
    else:
      print "Not working"


it doesn't work. self.reg never points to anything.

Any ideas?




More information about the Python-list mailing list