PyDocs

Nav

File Formats

ConfigParser.read_dict

configparser

method of ConfigParser · Added in 3.2 (source)
  • ConfigParser.read_dict(dictionary, source='<dict>')
Read configuration from a dictionary.

Keys are section names, values are dictionaries with keys and values
that should be present in the section. If the used dictionary type
preserves order, sections and their keys will be added in order.

All types held in the dictionary are converted to strings during
reading, including section names, option names and keys.

Optional second argument is the `source` specifying the name of the
dictionary being read.
1 Example
>>> parser = configparser.ConfigParser()
>>> parser.read_dict({'section1': {'key1': 'value1',
...                                'key2': 'value2',
...                                'key3': 'value3'},
...                   'section2': {'keyA': 'valueA',
...                                'keyB': 'valueB',
...                                'keyC': 'valueC'},
...                   'section3': {'foo': 'x',
...                                'bar': 'y',
...                                'baz': 'z'}
... })
>>> parser.sections()
['section1', 'section2', 'section3']
>>> [option for option in parser['section3']]
['foo', 'bar', 'baz']
from the Python docs
See Also
No see-alsos for configparser/ConfigParser.read_dict
0 Notes
No notes for ConfigParser.read_dict