[Python-checkins] python/dist/src/Doc/tut tut.tex,1.219,1.220

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed Dec 17 16:38:28 EST 2003


Update of /cvsroot/python/python/dist/src/Doc/tut
In directory sc8-pr-cvs1:/tmp/cvs-serv20145

Modified Files:
	tut.tex 
Log Message:
Guido grants a Christmas wish:  
  sorted() becomes a regular function instead of a classmethod.



Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.219
retrieving revision 1.220
diff -C2 -d -r1.219 -r1.220
*** tut.tex	6 Dec 2003 20:12:00 -0000	1.219
--- tut.tex	17 Dec 2003 21:38:26 -0000	1.220
***************
*** 2212,2215 ****
--- 2212,2229 ----
  \end{verbatim}
  
+ To loop over a sequence in sorted order, use the \function{sorted()}
+ function which returns a new sorted list while leaving the source
+ unaltered.
+ 
+ \begin{verbatim}
+ >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
+ >>> for f in sorted(set(basket)):
+ ...     print f
+ ... 	
+ apple
+ banana
+ orange
+ pear
+ \end{verbatim}
  
  \section{More on Conditions \label{conditions}}





More information about the Python-checkins mailing list