]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add doctest and improve readability for move_to_end() example. (GH-30370) (GH-30373)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 4 Jan 2022 05:55:38 +0000 (21:55 -0800)
committerGitHub <noreply@github.com>
Tue, 4 Jan 2022 05:55:38 +0000 (21:55 -0800)
Doc/library/collections.rst

index 8bf3cb6cb12da17cac0b0b792b5b8f3202f7027e..b8a717d883c0931fe1dca38d8e19071adb82d4b0 100644 (file)
@@ -1120,14 +1120,16 @@ Some differences from :class:`dict` still remain:
         Move an existing *key* to either end of an ordered dictionary.  The item
         is moved to the right end if *last* is true (the default) or to the
         beginning if *last* is false.  Raises :exc:`KeyError` if the *key* does
-        not exist::
+        not exist:
+
+        .. doctest::
 
             >>> d = OrderedDict.fromkeys('abcde')
             >>> d.move_to_end('b')
-            >>> ''.join(d.keys())
+            >>> ''.join(d)
             'acdeb'
             >>> d.move_to_end('b', last=False)
-            >>> ''.join(d.keys())
+            >>> ''.join(d)
             'bacde'
 
         .. versionadded:: 3.2