# -*- coding: utf-8 -*- """ # Config file [global] loglevel: WARNING logfile: - [section1] key_a: value key_b: morevalue [section2] key_c: othervalue key_d: differentvalue """ import configparser def print_sections(cp): cp.read_string(__doc__) for section in cp.sections(): print('{}: {}'.format(section, cp.items(section))) print() print('ConfigParser() with expected result:') cp = configparser.ConfigParser() print_sections(cp) print("ConfigParser(default_section='global') mangles section separation:") cp = configparser.ConfigParser(default_section='global') print_sections(cp) print("ConfigParser(interpolation=ExtendedInterpolation) fails with strange error:") cp = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation) print_sections(cp) # vim:set et ts=8 sw=4: