Python configparser get all from a section and write to new file
<p>how would one use python config parser to get every entry under a single section and write to a new file without actually specifying each entry</p>

<p>for example how would I go about getting everything under section "testing" and write to a new file without using config.get and listing every entry?</p>

<p>config file</p>

<pre><code>[testing]
test1=test23452
test2=test45235
test3=test54524
[donotneed]
something1=something
something2=somethingelse
</code></pre>

<p>I've tried the following just for testing purposes </p>

<pre><code>config = ConfigParser.ConfigParser()
    config.read(configFilePath)
    testing = {k:v for k,v in config.items('testing')}
    for x in testing:
        print (x)
</code></pre>

<p>but it's only printing the following</p>

<pre><code>test1
test3
test2
</code></pre>

<p>and not everything in that section, I need it to give me</p>

<pre><code>test1=test23452
test2=test45235
test3=test54524
</code></pre>

<p>"for x in testing" will just parse the keys of the dictionary 'testing' .</p>

<p>you need :
for x in testing.items():
  print x[0] + '=' + x[1]</p>

python parsing config python-config