@@ -942,7 +942,13 @@ interpolation if an option used is not defined elsewhere. ::
942
942
ConfigParser Objects
943
943
--------------------
944
944
945
- .. 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={})
945
+ .. class :: ConfigParser(defaults=None, dict_type=dict, allow_no_value=False, *, \
946
+ delimiters=('=', ':'), comment_prefixes=('#', ';'), \
947
+ inline_comment_prefixes=None, strict=True, \
948
+ empty_lines_in_values=True, \
949
+ default_section=configparser.DEFAULTSECT, \
950
+ interpolation=BasicInterpolation(), converters={}, \
951
+ allow_unnamed_section=False)
946
952
947
953
The main configuration parser. When *defaults * is given, it is initialized
948
954
into the dictionary of intrinsic defaults. When *dict_type * is given, it
@@ -990,6 +996,10 @@ ConfigParser Objects
990
996
converter gets its own corresponding :meth: `!get* ` method on the parser
991
997
object and section proxies.
992
998
999
+ When *allow_unnamed_section * is ``True `` (default: ``False ``),
1000
+ the first section name can be omitted. See the
1001
+ `"Unnamed Sections" section <#unnamed-sections >`_.
1002
+
993
1003
It is possible to read several configurations into a single
994
1004
:class: `ConfigParser `, where the most recently added configuration has the
995
1005
highest priority. Any conflicting keys are taken from the more recent
@@ -1039,6 +1049,9 @@ ConfigParser Objects
1039
1049
Raise a :exc: `MultilineContinuationError ` when *allow_no_value * is
1040
1050
``True ``, and a key without a value is continued with an indented line.
1041
1051
1052
+ .. versionchanged :: 3.13
1053
+ The *allow_unnamed_section * argument was added.
1054
+
1042
1055
.. method :: defaults()
1043
1056
1044
1057
Return a dictionary containing the instance-wide defaults.
@@ -1295,18 +1308,30 @@ RawConfigParser Objects
1295
1308
comment_prefixes=('#', ';'), \
1296
1309
inline_comment_prefixes=None, strict=True, \
1297
1310
empty_lines_in_values=True, \
1298
- default_section=configparser.DEFAULTSECT[, \
1299
- interpolation])
1311
+ default_section=configparser.DEFAULTSECT, \
1312
+ interpolation=BasicInterpolation(), converters={}, \
1313
+ allow_unnamed_section=False)
1300
1314
1301
1315
Legacy variant of the :class: `ConfigParser `. It has interpolation
1302
1316
disabled by default and allows for non-string section names, option
1303
1317
names, and values via its unsafe ``add_section `` and ``set `` methods,
1304
1318
as well as the legacy ``defaults= `` keyword argument handling.
1305
1319
1320
+ .. versionchanged :: 3.2
1321
+ *allow_no_value *, *delimiters *, *comment_prefixes *, *strict *,
1322
+ *empty_lines_in_values *, *default_section * and *interpolation * were
1323
+ added.
1324
+
1325
+ .. versionchanged :: 3.5
1326
+ The *converters * argument was added.
1327
+
1306
1328
.. versionchanged :: 3.8
1307
1329
The default *dict_type * is :class: `dict `, since it now preserves
1308
1330
insertion order.
1309
1331
1332
+ .. versionchanged :: 3.13
1333
+ The *allow_unnamed_section * argument was added.
1334
+
1310
1335
.. note ::
1311
1336
Consider using :class: `ConfigParser ` instead which checks types of
1312
1337
the values to be stored internally. If you don't want interpolation, you
0 commit comments