From: Ezio Melotti Date: Sat, 12 Sep 2009 01:52:05 +0000 (+0000) Subject: d.items() -> list(d.items()) in the examples X-Git-Tag: v3.2a1~2592 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c53a894a219135fedcba2c01388fda76065a5361;p=python d.items() -> list(d.items()) in the examples --- diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 1d82364be7..d7907b0776 100644 --- a/Doc/library/collections.rst +++ b/Doc/library/collections.rst @@ -538,7 +538,7 @@ sequence of key-value pairs into a dictionary of lists: >>> for k, v in s: ... d[k].append(v) ... - >>> d.items() + >>> list(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])] When each key is encountered for the first time, it is not already in the @@ -553,7 +553,7 @@ simpler and faster than an equivalent technique using :meth:`dict.setdefault`: >>> for k, v in s: ... d.setdefault(k, []).append(v) ... - >>> d.items() + >>> list(d.items()) [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])] Setting the :attr:`default_factory` to :class:`int` makes the @@ -565,7 +565,7 @@ languages): >>> for k in s: ... d[k] += 1 ... - >>> d.items() + >>> list(d.items()) [('i', 4), ('p', 2), ('s', 4), ('m', 1)] When a letter is first encountered, it is missing from the mapping, so the @@ -592,7 +592,7 @@ Setting the :attr:`default_factory` to :class:`set` makes the >>> for k, v in s: ... d[k].add(v) ... - >>> d.items() + >>> list(d.items()) [('blue', set([2, 4])), ('red', set([1, 3]))]