summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-01-17 23:39:39 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-01-17 23:39:39 (GMT)
commit02dd70be5cbc2dfaac79a34ae9aedd62d107a396 (patch)
tree35d154d2dd064b03481ac7fbbeb8c16bf6cea6b8
parent6f0d59bad32577c8383169bcca199071fcbd85f0 (diff)
downloadcpython-02dd70be5cbc2dfaac79a34ae9aedd62d107a396.zip
cpython-02dd70be5cbc2dfaac79a34ae9aedd62d107a396.tar.gz
cpython-02dd70be5cbc2dfaac79a34ae9aedd62d107a396.tar.bz2
The example for configparser was weird.
-rw-r--r--Doc/whatsnew/3.2.rst55
1 files changed, 31 insertions, 24 deletions
diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst
index 0d28baa..1128c28 100644
--- a/Doc/whatsnew/3.2.rst
+++ b/Doc/whatsnew/3.2.rst
@@ -1454,34 +1454,41 @@ duplicates are not allowed in a single configuration source.
Config parsers gained a new API based on the mapping protocol::
- >>> parser = ConfigParser()
- >>> parser.read_string("""
- [DEFAULT]
- monty = python
-
- [phrases]
- the = who
- full = metal jacket
- """)
- >>> parser['phrases']['full']
- 'metal jacket'
- >>> section = parser['phrases']
- >>> section['the']
- 'who'
- >>> section['british'] = '%(the)s %(full)s %(monty)s!'
- >>> parser['phrases']['british']
- 'who metal jacket python!'
- >>> 'british' in section
- True
-
-The new API is implemented on top of the classical API so custom parser
+ >>> parser = ConfigParser()
+ >>> parser.read_string("""
+ [DEFAULT]
+ location = upper left
+ visible = yes
+ editable = no
+ color = blue
+
+ [main]
+ title = Main Menu
+ color = green
+
+ [options]
+ title = Options
+ """)
+ >>> parser['main']['color']
+ 'green'
+ >>> parser['main']['editable']
+ 'no'
+ >>> section = parser['options']
+ >>> section['title']
+ 'Options'
+ >>> section['title'] = 'Options (editable: %(editable)s)'
+ >>> section['title']
+ 'Options (editable: no)'
+
+The new API is implemented on top of the classical API, so custom parser
subclasses should be able to use it without modifications.
The INI file structure accepted by config parsers can now be customized. Users
can specify alternative option/value delimiters and comment prefixes, change the
-name of the *DEFAULT* section or switch the interpolation syntax. Along with
-support for pluggable interpolation, an additional interpolation handler
-:class:`~configparser.ExtendedInterpolation` was introduced::
+name of the *DEFAULT* section or switch the interpolation syntax.
+
+The is support for pluggable interpolation including an additional interpolation
+handler :class:`~configparser.ExtendedInterpolation`::
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
>>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},