diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2004-12-03 14:57:21 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2004-12-03 14:57:21 (GMT) |
commit | 1cae3f57e7724539ef9cb7886e120ae21a838a39 (patch) | |
tree | 8f27625549b8cbc586bb455a23086c1cb4aa6ab3 /Doc/whatsnew | |
parent | 92e2495af6ab1d240978c98077981f024cddcf1c (diff) | |
download | cpython-1cae3f57e7724539ef9cb7886e120ae21a838a39.zip cpython-1cae3f57e7724539ef9cb7886e120ae21a838a39.tar.gz cpython-1cae3f57e7724539ef9cb7886e120ae21a838a39.tar.bz2 |
AAdd item. (And so it beegins again.)
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/whatsnew25.tex | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex index ba479db..c26be0a 100644 --- a/Doc/whatsnew/whatsnew25.tex +++ b/Doc/whatsnew/whatsnew25.tex @@ -37,7 +37,24 @@ Here are all of the changes that Python 2.5 makes to the core Python language. \begin{itemize} -\item TBD + +\item The \function{min()} and \function{max()} built-in functions +gained a \code{key} keyword argument analogous to the \code{key} +argument for \function{sort()}. This argument supplies a function +that takes a single argument and is called for every value in the list; +\function{min()}/\function{max()} will return the element with the +smallest/largest return value from this function. +For example, to find the longest string in a list, you can do: + +\begin{verbatim} +L = ['medium', 'longest', 'short'] +# Prints 'longest' +print max(L, key=len) +# Prints 'short', because lexicographically 'short' has the largest value +print max(L) +\end{verbatim} + +(Contributed by Steven Bethard and Raymond Hettinger.) \end{itemize} |