[Python-checkins] r88078 - python/branches/py3k/Doc/whatsnew/3.2.rst
raymond.hettinger
python-checkins at python.org
Tue Jan 18 00:39:39 CET 2011
Author: raymond.hettinger
Date: Tue Jan 18 00:39:39 2011
New Revision: 88078
Log:
The example for configparser was weird.
Modified:
python/branches/py3k/Doc/whatsnew/3.2.rst
Modified: python/branches/py3k/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/3.2.rst (original)
+++ python/branches/py3k/Doc/whatsnew/3.2.rst Tue Jan 18 00:39:39 2011
@@ -1454,34 +1454,41 @@
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
+ >>> 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
+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'},
More information about the Python-checkins
mailing list