summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-04 05:55:38 (GMT)
committerGitHub <noreply@github.com>2022-01-04 05:55:38 (GMT)
commit685b6285b9a7109c2c6dca04f32a585445dd0f04 (patch)
tree5fcdeddfb26fcfe8db6d055e1d0cf13e3c74bc37 /Doc/library
parent0b3c3cbbaf2967cc17531d65ece0969b0d2a2079 (diff)
downloadcpython-685b6285b9a7109c2c6dca04f32a585445dd0f04.zip
cpython-685b6285b9a7109c2c6dca04f32a585445dd0f04.tar.gz
cpython-685b6285b9a7109c2c6dca04f32a585445dd0f04.tar.bz2
Add doctest and improve readability for move_to_end() example. (GH-30370) (GH-30373)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/collections.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
index 8bf3cb6..b8a717d 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