According to what I read in the ConfigParser module, this should work, but it doesn't. Can anyone point out what I'm doing wrong?
The error I keep getting:
To me it looks like it is something wrong in the ConfigParser code, But I'm sure thats just foolish arrogance getting to me, because I of course keep insisting I'm right. :)
Code:
def writeinifile ( self, FILE='P:/INI/test.ini', SECTION='Testsection', OPTION='Item', VALUE='wheeee' ): p = ConfigParser() p.read(FILE) if not p.has_section ( SECTION ): p.add_section(SECTION) p.set(SECTION, OPTION, VALUE) p.write(FILE)
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win
32
Type "help", "copyright" , "credits" or "license" for more information.
>>> from INIfile import INI
>>> I = INI()
>>> I.writeinifile ( SECTION='Sectio n' )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\li b\INIfile.py", line 23, in writeinifile
p.write(fp=FILE )
File "C:\Python25\li b\ConfigParser. py", line 369, in write
fp.write("[%s]\n" % section)
AttributeError: 'str' object has no attribute 'write'
>>>
32
Type "help", "copyright" , "credits" or "license" for more information.
>>> from INIfile import INI
>>> I = INI()
>>> I.writeinifile ( SECTION='Sectio n' )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\li b\INIfile.py", line 23, in writeinifile
p.write(fp=FILE )
File "C:\Python25\li b\ConfigParser. py", line 369, in write
fp.write("[%s]\n" % section)
AttributeError: 'str' object has no attribute 'write'
>>>
Comment