diff --git a/pep-0372.txt b/pep-0372.txt index d9eeb3eb5..ae253554b 100644 --- a/pep-0372.txt +++ b/pep-0372.txt @@ -37,11 +37,11 @@ keys that are overwritten are not moved to the end. The following example shows the behavior for simple assignments: ->>> d = odict() ->>> d['parrot'] = 'dead' ->>> d['penguin'] = 'exploded' ->>> d.items() -[('parrot', 'dead'), ('penguin', 'exploded')] + >>> d = odict() + >>> d['parrot'] = 'dead' + >>> d['penguin'] = 'exploded' + >>> d.items() + [('parrot', 'dead'), ('penguin', 'exploded')] That the ordering is preserved makes an odict useful for a couple of situations: @@ -90,10 +90,10 @@ The constructor and ``update()`` both accept iterables of tuples as well as mappings like a dict does. Unlike a regular dictionary, the insertion order is preserved. ->>> d = odict([('a', 'b'), ('c', 'd')]) ->>> d.update({'foo': 'bar'}) ->>> d -collections.odict([('a', 'b'), ('c', 'd'), ('foo', 'bar')]) + >>> d = odict([('a', 'b'), ('c', 'd')]) + >>> d.update({'foo': 'bar'}) + >>> d + collections.odict([('a', 'b'), ('c', 'd'), ('foo', 'bar')]) If ordered dicts are updated from regular dicts, the ordering of new keys is of course undefined. @@ -102,13 +102,13 @@ All iteration methods as well as ``keys()``, ``values()`` and ``items()`` return the values ordered by the time the key was first inserted: ->>> d['spam'] = 'eggs' ->>> d.keys() -['a', 'c', 'foo', 'spam'] ->>> d.values() -['b', 'd', 'bar', 'eggs'] ->>> d.items() -[('a', 'b'), ('c', 'd'), ('foo', 'bar'), ('spam', 'eggs')] + >>> d['spam'] = 'eggs' + >>> d.keys() + ['a', 'c', 'foo', 'spam'] + >>> d.values() + ['b', 'd', 'bar', 'eggs'] + >>> d.items() + [('a', 'b'), ('c', 'd'), ('foo', 'bar'), ('spam', 'eggs')] New methods not available on dict: