python - How to write an INI file with ConfigParser with duplicate options -


i want write ini file duplicate options,ie:

[test] foo = value1 foo = value2 xxx = yyy 

with configparser.set last value writed.

config = configparser.configparser() config.read('example.cfg')  config.add_section('test') config.set('test', service['foo'], service['value1']) config.set('test', service['foo'], service['value2']) config.set('test', service['xxx'], service['yyy']) 

the result is:

[test] foo = value2 xxx = yyy 

is there way?

it looks isn't possible in simple way. default way configparser stores dict's, i.e. 1 value per unique key.

in similar question python's configparser unique keys per section suggestions go with:


Comments