On 22/03/2010 21:22, travel europe wrote:
I am getting the following error "ValueError: I/O operation on closed file" when running a module to pull data from the Windows registry. <code> import csv from winsys import registry key = r"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" fields = ["DisplayName", "Comments", "InstallDate"] # add to as required uninstall = registry.registry (key) with open ("installed.txt", "wb") as f: writer = csv.writer (f) writer.writerow (fields) for subkey in uninstall: info = dict (subkey.values ()) writer.writerow ([info.get (field) for field in fields]) <code>
The indentation's wrong. The line starting "for subkey in..." should be indented to the same level as the line above, placing it within context of the "with open (...):" from a few lines above. I've just checked the email I sent with that in, and it looks ok (on my email client) so I can only imagine that one of the various email clients / servers between us has munged the indentation. TJG _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32