how to write file with configparser

Chris Gonnerman chris.gonnerman at usa.net
Sat Apr 21 10:55:57 EDT 2001


<hlt2000 at hotmail.com> wrote in message
news:3ae15ddc.7279927 at news.xs4all.nl...
> I,m using the ConfigParser module to read my ini file. After my
> program has ran I want to update the ini file. With configdict.set I
> modify an option to a new value.
>
> How do I write this back onto my file system?
>
> cfgfile=open('config.ini',' rw')

Your problem is here.  Read/write access is like this:

    cfgfile=open('config.ini', 'r+')

> ...
> cfgdict.set(....)
> ...
> cfgdict.write(cfgfile)
>
> This gives an IOerror: (0,Error)
>
> What is the right way to do this?
>
> TIA,
> Hans






More information about the Python-list mailing list