Commit cca65313 authored by Benjamin Peterson's avatar Benjamin Peterson

use 3 space indents

parent 5b0c1e07
...@@ -17,23 +17,22 @@ The :mod:`functools` module defines the following functions: ...@@ -17,23 +17,22 @@ The :mod:`functools` module defines the following functions:
.. function:: cmp_to_key(func) .. function:: cmp_to_key(func)
Transform an old-style comparison function to a key-function. Used with Transform an old-style comparison function to a key-function. Used with
tools that accept key functions (such as :func:`sorted`, :func:`min`, tools that accept key functions (such as :func:`sorted`, :func:`min`,
:func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`, :func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`,
:func:`itertools.groupby`). :func:`itertools.groupby`). This function is primarily used as a transition
This function is primarily used as a transition tool for programs tool for programs being converted from Py2.x which supported the use of
being converted from Py2.x which supported the use of comparison comparison functions.
functions.
A compare function is any callable that accept two arguments, compares them,
A compare function is any callable that accept two arguments, compares and returns a negative number for less-than, zero for equality, or a positive
them, and returns a negative number for less-than, zero for equality, number for greater-than. A key function is a callable that accepts one
or a positive number for greater-than. A key function is a callable argument and returns another value that indicates the position in the desired
that accepts one argument and returns another value that indicates collation sequence.
the position in the desired collation sequence.
Example::
Example::
sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order
sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order
.. versionadded:: 3.2 .. versionadded:: 3.2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment