title: ConfigParser - Write to existing section
body: <p>I am a bit stuck at the <code>ConfigParser</code>.</p>
  
  <p>I want to add a specific setting to a existing section.</p>
  
  <p>I do:</p>
  
  <pre><code>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:
  </code></pre>
  
  <p>Then it shows:</p>
  
  <pre><code>...
    File "&lt;stdin&gt;", line 2
  
      ^
  IndentationError: expected an indented block
  &gt;&gt;&gt;
  </code></pre>
  
  <p><strong>Edit #1</strong></p>
  
  <p>Now i tried it with the iniparse module. I did:</p>
  
  <pre><code>from iniparse import INIConfig
  cfg = INIConfig(open('/etc/yum.repos.d/epel.repo'))
  cfg.epel.priority=10
  f = open('/etc/yum.repos.d/epel.repo', 'w')
  print &gt;&gt;f, cfg
  f.close()
  </code></pre>
  
  <p>Unfortunately it deletes the old content. How can i solve this?</p>
  
  <p><strong>Edit #2</strong></p>
  
  <p>It looks like that it works now.</p>
  
  <pre><code>f = open('/etc/yum.repos.d/epel.repo', 'wb')
  </code></pre>
  
  <p>did the trick.</p>