summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorlit <litlighilit@foxmail.com>2024-11-05 02:58:15 (GMT)
committerGitHub <noreply@github.com>2024-11-05 02:58:15 (GMT)
commitd9602265479bcd96dc377d92a34556baf34ac3cd (patch)
treef8efbc3cfb29d53f677d0b14b49699479c804c05 /Doc/library
parent78015818c2601db842d101cad6ce2319c921935f (diff)
downloadcpython-d9602265479bcd96dc377d92a34556baf34ac3cd.zip
cpython-d9602265479bcd96dc377d92a34556baf34ac3cd.tar.gz
cpython-d9602265479bcd96dc377d92a34556baf34ac3cd.tar.bz2
gh-125436: Doc: Add missing ``allow_unnamed_section`` parameter to ``ConfigParser`` documentation (#125437)
Add missing ``allow_unnamed_section`` parameter to ``ConfigParser`` doc, as well as to it's parent ``RawConfigParser``. Split too long line on ``ConfigParser`` signature. Add some sections about when some of ``RawConfigParser`` parameters were added.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/configparser.rst31
1 files changed, 28 insertions, 3 deletions
diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst
index 3aad6f7..ac0f3fc 100644
--- a/Doc/library/configparser.rst
+++ b/Doc/library/configparser.rst
@@ -942,7 +942,13 @@ interpolation if an option used is not defined elsewhere. ::
ConfigParser Objects
--------------------
-.. class:: ConfigParser(defaults=None, dict_type=dict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configparser.DEFAULTSECT, interpolation=BasicInterpolation(), converters={})
+.. class:: ConfigParser(defaults=None, dict_type=dict, allow_no_value=False, *, \
+ delimiters=('=', ':'), comment_prefixes=('#', ';'), \
+ inline_comment_prefixes=None, strict=True, \
+ empty_lines_in_values=True, \
+ default_section=configparser.DEFAULTSECT, \
+ interpolation=BasicInterpolation(), converters={}, \
+ allow_unnamed_section=False)
The main configuration parser. When *defaults* is given, it is initialized
into the dictionary of intrinsic defaults. When *dict_type* is given, it
@@ -990,6 +996,10 @@ ConfigParser Objects
converter gets its own corresponding :meth:`!get*` method on the parser
object and section proxies.
+ When *allow_unnamed_section* is ``True`` (default: ``False``),
+ the first section name can be omitted. See the
+ `"Unnamed Sections" section <#unnamed-sections>`_.
+
It is possible to read several configurations into a single
:class:`ConfigParser`, where the most recently added configuration has the
highest priority. Any conflicting keys are taken from the more recent
@@ -1039,6 +1049,9 @@ ConfigParser Objects
Raise a :exc:`MultilineContinuationError` when *allow_no_value* is
``True``, and a key without a value is continued with an indented line.
+ .. versionchanged:: 3.13
+ The *allow_unnamed_section* argument was added.
+
.. method:: defaults()
Return a dictionary containing the instance-wide defaults.
@@ -1295,18 +1308,30 @@ RawConfigParser Objects
comment_prefixes=('#', ';'), \
inline_comment_prefixes=None, strict=True, \
empty_lines_in_values=True, \
- default_section=configparser.DEFAULTSECT[, \
- interpolation])
+ default_section=configparser.DEFAULTSECT, \
+ interpolation=BasicInterpolation(), converters={}, \
+ allow_unnamed_section=False)
Legacy variant of the :class:`ConfigParser`. It has interpolation
disabled by default and allows for non-string section names, option
names, and values via its unsafe ``add_section`` and ``set`` methods,
as well as the legacy ``defaults=`` keyword argument handling.
+ .. versionchanged:: 3.2
+ *allow_no_value*, *delimiters*, *comment_prefixes*, *strict*,
+ *empty_lines_in_values*, *default_section* and *interpolation* were
+ added.
+
+ .. versionchanged:: 3.5
+ The *converters* argument was added.
+
.. versionchanged:: 3.8
The default *dict_type* is :class:`dict`, since it now preserves
insertion order.
+ .. versionchanged:: 3.13
+ The *allow_unnamed_section* argument was added.
+
.. note::
Consider using :class:`ConfigParser` instead which checks types of
the values to be stored internally. If you don't want interpolation, you