@@ -445,20 +445,19 @@ the :meth:`__init__` options:
445
445
Hint: if you want to specify default values for a specific section, use
446
446
:meth: `read_dict ` before you read the actual file.
447
447
448
- * *dict_type *, default value: :class: `collections.OrderedDict `
448
+ * *dict_type *, default value: :class: `dict `
449
449
450
450
This option has a major impact on how the mapping protocol will behave and how
451
- the written configuration files look. With the default ordered
452
- dictionary, every section is stored in the order they were added to the
453
- parser. Same goes for options within sections.
451
+ the written configuration files look. With the standard dictionary, every
452
+ section is stored in the order they were added to the parser. Same goes for
453
+ options within sections.
454
454
455
455
An alternative dictionary type can be used for example to sort sections and
456
- options on write-back. You can also use a regular dictionary for performance
457
- reasons.
456
+ options on write-back.
458
457
459
458
Please note: there are ways to add a set of key-value pairs in a single
460
459
operation. When you use a regular dictionary in those operations, the order
461
- of the keys may be random . For example:
460
+ of the keys will be ordered . For example:
462
461
463
462
.. doctest ::
464
463
@@ -474,40 +473,9 @@ the :meth:`__init__` options:
474
473
... ' baz' : ' z' }
475
474
... })
476
475
>>> parser.sections() # doctest: +SKIP
477
- ['section3', 'section2', 'section1']
478
- >>> [option for option in parser[' section3' ]] # doctest: +SKIP
479
- ['baz', 'foo', 'bar']
480
-
481
- In these operations you need to use an ordered dictionary as well:
482
-
483
- .. doctest ::
484
-
485
- >>> from collections import OrderedDict
486
- >>> parser = configparser.ConfigParser()
487
- >>> parser.read_dict(
488
- ... OrderedDict((
489
- ... (' s1' ,
490
- ... OrderedDict((
491
- ... (' 1' , ' 2' ),
492
- ... (' 3' , ' 4' ),
493
- ... (' 5' , ' 6' ),
494
- ... ))
495
- ... ),
496
- ... (' s2' ,
497
- ... OrderedDict((
498
- ... (' a' , ' b' ),
499
- ... (' c' , ' d' ),
500
- ... (' e' , ' f' ),
501
- ... ))
502
- ... ),
503
- ... ))
504
- ... )
505
- >>> parser.sections() # doctest: +SKIP
506
- ['s1', 's2']
507
- >>> [option for option in parser[' s1' ]] # doctest: +SKIP
508
- ['1', '3', '5']
509
- >>> [option for option in parser[' s2' ].values()] # doctest: +SKIP
510
- ['b', 'd', 'f']
476
+ ['section1', 'section2', 'section3']
477
+ >>> [option for option in parser[' section3' ]] # doctest: +SKIP
478
+ ['foo', 'bar', 'baz']
511
479
512
480
* *allow_no_value *, default value: ``False ``
513
481
0 commit comments