[Python-checkins] Add doctest and improve readability for move_to_end() example. (GH-30370) (GH-30373)

rhettinger webhook-mailer at python.org
Tue Jan 4 00:55:46 EST 2022


https://github.com/python/cpython/commit/685b6285b9a7109c2c6dca04f32a585445dd0f04
commit: 685b6285b9a7109c2c6dca04f32a585445dd0f04
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2022-01-03T21:55:38-08:00
summary:

Add doctest and improve readability for move_to_end() example. (GH-30370) (GH-30373)

files:
M Doc/library/collections.rst

diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 8bf3cb6cb12da..b8a717d883c09 100644
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -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



More information about the Python-checkins mailing list