[Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.2, 1.3

akuchling at users.sourceforge.net akuchling at users.sourceforge.net
Fri Dec 3 15:57:24 CET 2004


Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv315

Modified Files:
	whatsnew25.tex 
Log Message:
AAdd item.  (And so it beegins again.)

Index: whatsnew25.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- whatsnew25.tex	3 Dec 2004 13:54:09 -0000	1.2
+++ whatsnew25.tex	3 Dec 2004 14:57:21 -0000	1.3
@@ -37,7 +37,24 @@
 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}
 



More information about the Python-checkins mailing list