Hi, I'm trying and updating an .ini file with ConfigParser but each time
I call 'write', it appends the whole options another time to the file.
For example :
Here's the inital ini file

[section1]
foodir: %(dir)s/whatever
dir: foo

Here's my code :
filename = ...
config = ConfigParser.ConfigParser()
config.read(filename)
config.set('section1', 'dir', 'anotherdir')
f = open(filename, 'r+')
config.write(f)
f.close()

Then I get :

[section1]
foodir: %(dir)s/whatever
dir: anotherdir

[section1]
foodir: %(dir)s/whatever
dir: foo


I tried also with 'w', 'w+', 'a' ...

What's the correct way to avoid this ?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to