Skip to content

Commit 407f3dd

Browse files
miss-islingtonWolfgang Maier
authored andcommitted
fix dangling keyfunc examples in documentation of heapq and sorted (GH-1432)
* fix dangling mention of key=str.lower in heapq doc * Fix dangling mention of keyfunc example for sorted() (cherry picked from commit 6bdb6f7) Co-authored-by: Wolfgang Maier <[email protected]>
1 parent 08ba7eb commit 407f3dd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Doc/library/functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,8 +1383,8 @@ are always available. They are listed here in alphabetical order.
13831383
Has two optional arguments which must be specified as keyword arguments.
13841384

13851385
*key* specifies a function of one argument that is used to extract a comparison
1386-
key from each list element: ``key=str.lower``. The default value is ``None``
1387-
(compare the elements directly).
1386+
key from each element in *iterable* (for example, ``key=str.lower``). The
1387+
default value is ``None`` (compare the elements directly).
13881388

13891389
*reverse* is a boolean value. If set to ``True``, then the list elements are
13901390
sorted as if each comparison were reversed.

Doc/library/heapq.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ The module also offers three general purpose functions based on heaps.
110110

111111
Return a list with the *n* largest elements from the dataset defined by
112112
*iterable*. *key*, if provided, specifies a function of one argument that is
113-
used to extract a comparison key from each element in the iterable:
114-
``key=str.lower`` Equivalent to: ``sorted(iterable, key=key,
115-
reverse=True)[:n]``
113+
used to extract a comparison key from each element in *iterable* (for example,
114+
``key=str.lower``). Equivalent to: ``sorted(iterable, key=key,
115+
reverse=True)[:n]``.
116116

117117

118118
.. function:: nsmallest(n, iterable, key=None)
119119

120120
Return a list with the *n* smallest elements from the dataset defined by
121121
*iterable*. *key*, if provided, specifies a function of one argument that is
122-
used to extract a comparison key from each element in the iterable:
123-
``key=str.lower`` Equivalent to: ``sorted(iterable, key=key)[:n]``
122+
used to extract a comparison key from each element in *iterable* (for example,
123+
``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
124124

125125

126126
The latter two functions perform best for smaller values of *n*. For larger

0 commit comments

Comments
 (0)