ConfigParser - Write to existing section

configuration-files, python

Solution

Simply,

   with open('epel.cfg', 'wb') as configfile:
        config.write(configfile)

See here for examples and documentation.

Problem

I am a bit stuck at the `ConfigParser`. I want to add a specific setting to a existing section. I do: ``` import ConfigParser Config = ConfigParser.ConfigParser() Config Config.read("/etc/yum.repos.d/epel.repo") Config.sections() Config.set('epel','priority',10) with open('/etc/yum.repos.d/epel.repo', 'w') as fout: ``` Then it shows: ``` ... File "<stdin>", line 2 ^ IndentationError: expected an indented block >>> ```

Original source

Related problems