diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2022-01-03 22:26:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 22:26:08 (GMT) |
commit | 770f43d47e8e15747f4f3884992a344f3b547c67 (patch) | |
tree | 8a2650ffcbcd8765ba60d8c678376d0e23a02950 /Doc/library/collections.rst | |
parent | 51700bf08b0dd4baf998440b2ebfaa488a2855ba (diff) | |
download | cpython-770f43d47e8e15747f4f3884992a344f3b547c67.zip cpython-770f43d47e8e15747f4f3884992a344f3b547c67.tar.gz cpython-770f43d47e8e15747f4f3884992a344f3b547c67.tar.bz2 |
Add doctest and improve readability for move_to_end() example. (#30370)
Diffstat (limited to 'Doc/library/collections.rst')
-rw-r--r-- | Doc/library/collections.rst | 8 |
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 |