[python-win32] Problem writing ini file with ConfigParser

Tony Cappellini tony at tcapp.com
Tue Apr 20 23:29:11 EDT 2004


On Windows 2000, using Python 2.3.3

After sifting through the docs for ConfigPArser, and manually banging in a
script in PythonWin, the ConfigParser is getting an exception during the
write,
I don't understand what the problem is

I've gone in with edit, and changed the file, and saved it, so admin
rights and read only don't sem to be a problem, from the editor.


 cfg=ConfigParser.ConfigParser()
fp=open(r"c:\winnt\system32\gpib.ini")
cfg.readfp(fp)
 cfg.read(r"c:\winnt\system32\gpib.ini")
cfg.set('GPIB0', 'sc','no')
cfg.get('GPIB0', 'sc')
'no'
cfg.write(fp)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "C:\Python23\lib\ConfigParser.py", line 363, in write
    fp.write("[%s]\n" % section)
IOError: (0, 'Error')

Any ideas what is causing the error ?

I don't have the file open in any other programs-


Tony





More information about the Python-win32 mailing list