]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix dangling keyfunc examples in documentation of heapq and sorted (GH-1432)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 15 Oct 2018 19:19:08 +0000 (12:19 -0700)
committerBrian Curtin <brian@python.org>
Mon, 15 Oct 2018 19:19:08 +0000 (13:19 -0600)
* fix dangling mention of key=str.lower in heapq doc

* Fix dangling mention of keyfunc example for sorted()
(cherry picked from commit 6bdb6f7675922e601e742758c7c240a751fd365b)

Co-authored-by: Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de>
Doc/library/functions.rst
Doc/library/heapq.rst

index bb472862e493839dac8e5c485262f9428473c4ec..c0f4ffd2cb2a8003b4d71bd765eb0d36df9a30ab 100644 (file)
@@ -1405,8 +1405,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.
index 0b1a3c8b00ceb5a90f6b68021ae2a49a11046578..8b00f7b27959b68188a8cc9a5506b943ae6ae770 100644 (file)
@@ -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