[Python-checkins] fix dangling keyfunc examples in documentation of heapq and sorted (#1432)
Brian Curtin
webhook-mailer at python.org
Mon Oct 15 15:06:57 EDT 2018
https://github.com/python/cpython/commit/6bdb6f7675922e601e742758c7c240a751fd365b
commit: 6bdb6f7675922e601e742758c7c240a751fd365b
branch: master
author: Wolfgang Maier <wolfgang.maier at biologie.uni-freiburg.de>
committer: Brian Curtin <brian at python.org>
date: 2018-10-15T13:06:53-06:00
summary:
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()
files:
M Doc/library/functions.rst
M Doc/library/heapq.rst
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 17960eb9c10e..e7b98eb44b2e 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1412,8 +1412,8 @@ are always available. They are listed here in alphabetical order.
Has two optional arguments which must be specified as keyword arguments.
*key* specifies a function of one argument that is used to extract a comparison
- key from each list element: ``key=str.lower``. The default value is ``None``
- (compare the elements directly).
+ key from each element in *iterable* (for example, ``key=str.lower``). The
+ default value is ``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the list elements are
sorted as if each comparison were reversed.
diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst
index 0b1a3c8b00ce..8b00f7b27959 100644
--- a/Doc/library/heapq.rst
+++ b/Doc/library/heapq.rst
@@ -112,17 +112,17 @@ The module also offers three general purpose functions based on heaps.
Return a list with the *n* largest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
- used to extract a comparison key from each element in the iterable:
- ``key=str.lower`` Equivalent to: ``sorted(iterable, key=key,
- reverse=True)[:n]``
+ used to extract a comparison key from each element in *iterable* (for example,
+ ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key,
+ reverse=True)[:n]``.
.. function:: nsmallest(n, iterable, key=None)
Return a list with the *n* smallest elements from the dataset defined by
*iterable*. *key*, if provided, specifies a function of one argument that is
- used to extract a comparison key from each element in the iterable:
- ``key=str.lower`` Equivalent to: ``sorted(iterable, key=key)[:n]``
+ used to extract a comparison key from each element in *iterable* (for example,
+ ``key=str.lower``). Equivalent to: ``sorted(iterable, key=key)[:n]``.
The latter two functions perform best for smaller values of *n*. For larger
More information about the Python-checkins
mailing list