ConfigParser instance has no attribute '__setitem__'
<p>i'm trying to initialize the config file
</p>

<pre><code>import ConfigParser

config = ConfigParser.ConfigParser()
config['Testing'] = {"name": "Yohannes", "age": 10}
with open("test.ini", "w") as configFile: 
    config.write(configFile)
</code></pre>

<p>but it keeps throwing this error </p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\user\workspace\ObjectDetection\src\confWriter.py", line 9, in &lt;module&gt;
    config['Testing'] = {"name": "Yohannes", "age": 10}
AttributeError: ConfigParser instance has no attribute '__setitem__'
</code></pre>

<p>I searched everywhere but didn't find anything</p>

<p>You are simply not using it right. <a href="https://docs.python.org/2/library/configparser.html#examples" rel="nofollow">Here</a> you can find examples.</p>

<pre><code>config = ConfigParser.ConfigParser()
config.add_section('Testing')
config.set('Testing', 'name', 'Yohannes')
config.set('Testing', 'age', 10)
</code></pre>

<p>About the error you are getting you can read <a href="https://docs.python.org/3/reference/datamodel.html#object.%5F%5Fsetitem%5F%5F" rel="nofollow">here</a>:</p>

<blockquote>
  <p><code>object.__setitem__(self, key, value)</code>
  Called to implement assignment to <code>self[key]</code>.</p>
</blockquote>

python python-2.7 file configuration