Skip to content

Commit c804a59

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 1370832 commit c804a59

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
@@ -1405,8 +1405,8 @@ are always available. They are listed here in alphabetical order.
14051405
Has two optional arguments which must be specified as keyword arguments.
14061406

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

14111411
*reverse* is a boolean value. If set to ``True``, then the list elements are
14121412
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
@@ -112,17 +112,17 @@ The module also offers three general purpose functions based on heaps.
112112

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

119119

120120
.. function:: nsmallest(n, iterable, key=None)
121121

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

127127

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

0 commit comments

Comments
 (0)