[New-bugs-announce] [issue37779] configparser: add documentation about several read() behaviour

Stéphane Blondon report at bugs.python.org
Tue Aug 6 16:22:40 EDT 2019


New submission from Stéphane Blondon <stephane.blondon at gmail.com>:

The documentation is not explicit about the behaviour if several files are read by the same ConfigParser: the data are not reset between two read().

I suggest to add such information in the documentation. There is a draft:

=== start ===
When a `ConfigParser` instance make several calls of `read_file()`, `read_string()` or `read_dict()` functions, the previous data will be overriden by the new ones. Otherwise, the previous data is kept. This behaviour is equivalent to a `read()` call with several files passed to `filenames` parameter`.

Example:
config = configparser.ConfigParser()
s = """
[spam]
alpha=1
"""
config.read_string(s)
# dict(config["spam"]) == {'alpha': '1'}
config.read_string("")
# dict(config["spam"]) == {'alpha': '1'}
=== end ===

What do you think about it?
I can do a PR but I wonder where is the best location in the documentation to insert it.

At the end of the 'Quick start paragraph' (https://docs.python.org/3/library/configparser.html#quick-start)? Or perhaps a new paragraph after 'Fallback Values'? Other location?

----------
components: Library (Lib)
messages: 349133
nosy: sblondon
priority: normal
severity: normal
status: open
title: configparser: add documentation about several read() behaviour
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37779>
_______________________________________


More information about the New-bugs-announce mailing list