By setting the same parameter multiple times with ConfigParser
I would like to read a config file with Python ConfigParser module:
[asection]
option_a = first_value
option_a = second_value
And I want to get a list of values specified for option_a option. I've tried the following:
test = """[asection]
option_a = first_value
option_a = second_value
"""
import ConfigParser, StringIO
f = StringIO.StringIO(test)
parser = ConfigParser.ConfigParser()
parser.readfp(f)
print parser.items()
What are the outputs:
[('option_a', 'second_value')]
While I was hoping:
[('option_a', 'first_value'), ('option_a', 'second_value')]
Or better yet:
[('option_a', ['first_value', 'second_value'])]
Is there a way to do this using ConfigParser? Another idea?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: