summaryrefslogtreecommitdiffstats
path: root/Doc/glossary.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-11-26 08:20:18 (GMT)
committerGeorg Brandl <georg@python.org>2010-11-26 08:20:18 (GMT)
commit3b85b9b4772251e1e6fc4172a4cfe99f4948d393 (patch)
treeb3b3e52e2d4fd69c2fca649a1645ce99b45644df /Doc/glossary.rst
parent8b63b9bb02b7a3d35f32e41f433877d4da41bab4 (diff)
downloadcpython-3b85b9b4772251e1e6fc4172a4cfe99f4948d393.zip
cpython-3b85b9b4772251e1e6fc4172a4cfe99f4948d393.tar.gz
cpython-3b85b9b4772251e1e6fc4172a4cfe99f4948d393.tar.bz2
Merged revisions 85843,85849-85850,85867,85907,85914,86134,86187,86315-86316,86390,86424-86425,86428 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85843 | georg.brandl | 2010-10-26 08:59:23 +0200 (Di, 26 Okt 2010) | 1 line Markup fix. ........ r85849 | georg.brandl | 2010-10-26 21:31:06 +0200 (Di, 26 Okt 2010) | 1 line #10200: typo. ........ r85850 | georg.brandl | 2010-10-26 21:58:11 +0200 (Di, 26 Okt 2010) | 1 line #10200: typo. ........ r85867 | georg.brandl | 2010-10-27 22:01:51 +0200 (Mi, 27 Okt 2010) | 1 line Add David. ........ r85907 | georg.brandl | 2010-10-29 06:54:13 +0200 (Fr, 29 Okt 2010) | 1 line #10222: fix for overzealous AIX compiler. ........ r85914 | georg.brandl | 2010-10-29 08:17:38 +0200 (Fr, 29 Okt 2010) | 1 line (?:...) is a non-capturing, but still grouping construct. ........ r86134 | georg.brandl | 2010-11-03 08:41:00 +0100 (Mi, 03 Nov 2010) | 1 line A newline in lineno output breaks pyframe output. ........ r86187 | georg.brandl | 2010-11-05 08:10:41 +0100 (Fr, 05 Nov 2010) | 1 line Move glossary entry to the right position and fix link. ........ r86315 | georg.brandl | 2010-11-08 12:05:18 +0100 (Mo, 08 Nov 2010) | 1 line Fix latex conversion glitch in property/feature descriptions. ........ r86316 | georg.brandl | 2010-11-08 12:08:35 +0100 (Mo, 08 Nov 2010) | 1 line Fix typo. ........ r86390 | georg.brandl | 2010-11-10 08:57:10 +0100 (Mi, 10 Nov 2010) | 1 line Fix typo. ........ r86424 | georg.brandl | 2010-11-12 07:19:48 +0100 (Fr, 12 Nov 2010) | 1 line Build a PDF of the FAQs too. ........ r86425 | georg.brandl | 2010-11-12 07:20:12 +0100 (Fr, 12 Nov 2010) | 1 line #10008: Fix duplicate index entry. ........ r86428 | georg.brandl | 2010-11-12 09:09:26 +0100 (Fr, 12 Nov 2010) | 1 line Fix weird line block in table. ........
Diffstat (limited to 'Doc/glossary.rst')
-rw-r--r--Doc/glossary.rst22
1 files changed, 21 insertions, 1 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 24bbb37..161e52c 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -356,6 +356,26 @@ Glossary
More information can be found in :ref:`typeiter`.
+ key function
+ A key function or collation function is a callable that returns a value
+ used for sorting or ordering. For example, :func:`locale.strxfrm` is
+ used to produce a sort key that is aware of locale specific sort
+ conventions.
+
+ A number of tools in Python accept key functions to control how elements
+ are ordered or grouped. They include :func:`min`, :func:`max`,
+ :func:`sorted`, :meth:`list.sort`, :func:`heapq.nsmallest`,
+ :func:`heapq.nlargest`, and :func:`itertools.groupby`.
+
+ There are several ways to create a key function. For example. the
+ :meth:`str.lower` method can serve as a key function for case insensitive
+ sorts. Alternatively, an ad-hoc key function can be built from a
+ :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
+ the :mod:`operator` module provides three key function constuctors:
+ :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and
+ :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO
+ <sortinghowto>` for examples of how to create and use key functions.
+
keyword argument
Arguments which are preceded with a ``variable_name=`` in the call.
The variable name designates the local name in the function to which the
@@ -379,7 +399,7 @@ Glossary
:keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also,
the :mod:`operator` module provides three key function constuctors:
:func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and
- :func:`~operator.methodcaller`. See the :ref:`sorting-howto` for
+ :func:`~operator.methodcaller`. See the :ref:`sortinghowto` for
examples of how to create and use key functions.
lambda