[Python-checkins] r70032 - peps/trunk/pep-0372.txt
raymond.hettinger
python-checkins at python.org
Fri Feb 27 22:36:22 CET 2009
Author: raymond.hettinger
Date: Fri Feb 27 22:36:22 2009
New Revision: 70032
Log:
Fix markup.
Modified:
peps/trunk/pep-0372.txt
Modified: peps/trunk/pep-0372.txt
==============================================================================
--- peps/trunk/pep-0372.txt (original)
+++ peps/trunk/pep-0372.txt Fri Feb 27 22:36:22 2009
@@ -135,10 +135,10 @@
The same as for regular dicts: The latter item overrides the
former. This has the side-effect that the position of the first
- key is used because only the value is actually overwritten:
+ key is used because only the value is actually overwritten::
- >>> odict([('a', 1), ('b', 2), ('a', 3)])
- collections.odict([('a', 3), ('b', 2)])
+ >>> odict([('a', 1), ('b', 2), ('a', 3)])
+ collections.odict([('a', 3), ('b', 2)])
This behavior is consistent with existing implementations in
Python, the PHP array and the hashmap in Ruby 1.9.
@@ -183,7 +183,7 @@
How well does odict work with the json module, PyYAML, and ConfigParser?
- For json, the good news is that json's encoder respects odict's iteration order:
+ For json, the good news is that json's encoder respects odict's iteration order::
>>> items = [('one', 1), ('two', 2), ('three',3), ('four',4), ('five',5)]
>>> json.dumps(OrderedDict(items))
@@ -193,13 +193,13 @@
dictionary so order is lost before the object hook sees it. This
problem is being fixed for Python 2.7/3.1 by adding an new hook that
preserves order (see http://bugs.python.org/issue5381 ).
- With the new hook, order can be preserved:
+ With the new hook, order can be preserved::
>>> jtext = '{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}'
>>> json.loads(jtext, object_pairs_hook=OrderedDict)
OrderedDict({'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5})
- For PyYAML, a full round-trip is problem free:
+ For PyYAML, a full round-trip is problem free::
>>> ytext = yaml.dump(OrderedDict(items))
>>> print ytext
@@ -213,8 +213,8 @@
>>> yaml.load(ytext)
OrderedDict({'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5})
- For the ConfigParser module, round-tripping is problem free. Custom
- dicts were added in Py2.6 specifically to support ordered dictionaries:
+ For the ConfigParser module, round-tripping is problem free. Custom
+ dicts were added in Py2.6 specifically to support ordered dictionaries::
>>> config = ConfigParser(dict_type=OrderedDict)
>>> config.read('myconfig.ini')
More information about the Python-checkins
mailing list