From: Raymond Hettinger Date: Mon, 3 Jan 2022 22:26:08 +0000 (-0800) Subject: Add doctest and improve readability for move_to_end() example. (#30370) X-Git-Tag: v3.11.0a4~98 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=770f43d47e8e15747f4f3884992a344f3b547c67;p=thirdparty%2FPython%2Fcpython.git Add doctest and improve readability for move_to_end() example. (#30370) --- diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst index 8bf3cb6cb12d..b8a717d883c0 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