On Apr 19, 6:20 am, hellt <[EMAIL PROTECTED]> wrote: > HI all, i found winreg module > fromhttp://www.rutherfurd.net/python/winreg/index.html > very useful and simple, instead _winreg. > > But i have a problem with this module, in its iterable part. > > look at the following code > > key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum") > for i in key.values: > print i.value > > and that is the exception > > Traceback (most recent call last): > File "D:\.Projects\python\temp.py", line 21, in <module> > for i in key.values: > File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next > return self.values[self.index - 1] > File "C:\Python25\Lib\site-packages\winreg.py", line 289, in > __getitem__ > name = _winreg.EnumValue(self.hkey, key)[0] > WindowsError: [Error 259] No more data is available > > so there is some problem with iterate, i think > i am still a beginner, so i cant understand why this appears, and what > should i fix. > > if anyone have some time to look closer to this module, i will > appreciate this very much.
The problem is not in your code, but in the module. The EnumValue() and EnumKey() functions in the _winreg module raise WindowsError when there are no more keys or values to retrieve. So, go inside the module and modify that line to something like: # There should be a for or a while loop around here try: name = _winreg.EnumValue(key, index) except EnvironmentError: -- http://mail.python.org/mailman/listinfo/python-list