Skip to content

Commit 6bdb6f7

Browse files
Wolfgang Maierbriancurtin
Wolfgang Maier
authored andcommitted
fix dangling keyfunc examples in documentation of heapq and sorted (#1432)
* fix dangling mention of key=str.lower in heapq doc * Fix dangling mention of keyfunc example for sorted()
1 parent 18fb1fb commit 6bdb6f7

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

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

14181418
*reverse* is a boolean value. If set to ``True``, then the list elements are
14191419
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)