Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
02dd70be
Commit
02dd70be
authored
Jan 17, 2011
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The example for configparser was weird.
parent
6f0d59ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
24 deletions
+31
-24
Doc/whatsnew/3.2.rst
Doc/whatsnew/3.2.rst
+31
-24
No files found.
Doc/whatsnew/3.2.rst
View file @
02dd70be
...
@@ -1454,34 +1454,41 @@ duplicates are not allowed in a single configuration source.
...
@@ -1454,34 +1454,41 @@ duplicates are not allowed in a single configuration source.
Config parsers gained a new API based on the mapping protocol::
Config parsers gained a new API based on the mapping protocol::
>>> parser = ConfigParser()
>>> parser = ConfigParser()
>>> parser.read_string("""
>>> parser.read_string("""
[DEFAULT]
[DEFAULT]
monty = python
location = upper left
visible = yes
[phrases]
editable = no
the = who
color = blue
full = metal jacket
""")
[main]
>>> parser['phrases']['full']
title = Main Menu
'metal jacket'
color = green
>>> section = parser['phrases']
>>> section['the']
[options]
'who'
title = Options
>>> section['british'] = '%(the)s %(full)s %(monty)s!'
""")
>>> parser['phrases']['british']
>>> parser['main']['color']
'who metal jacket python!'
'green'
>>> 'british' in section
>>> parser['main']['editable']
True
'no'
>>> section = parser['options']
The new API is implemented on top of the classical API so custom parser
>>> 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.
subclasses should be able to use it without modifications.
The INI file structure accepted by config parsers can now be customized. Users
The INI file structure accepted by config parsers can now be customized. Users
can specify alternative option/value delimiters and comment prefixes, change the
can specify alternative option/value delimiters and comment prefixes, change the
name of the *DEFAULT* section or switch the interpolation syntax. Along with
name of the *DEFAULT* section or switch the interpolation syntax.
support for pluggable interpolation, an additional interpolation handler
:class:`~configparser.ExtendedInterpolation` was introduced::
The is support for pluggable interpolation including an additional interpolation
handler :class:`~configparser.ExtendedInterpolation`::
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
>>> parser = ConfigParser(interpolation=ExtendedInterpolation())
>>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},
>>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment