[Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.5, 1.6

akuchling at users.sourceforge.net akuchling at users.sourceforge.net
Sat Nov 8 10:58:51 EST 2003


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

Modified Files:
	whatsnew24.tex 
Log Message:
Add some recent changes

Index: whatsnew24.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** whatsnew24.tex	21 Oct 2003 12:48:23 -0000	1.5
--- whatsnew24.tex	8 Nov 2003 15:58:49 -0000	1.6
***************
*** 28,33 ****
  
  %======================================================================
  
! % Large, PEP-level features and changes should be described here.
  
  
--- 28,58 ----
  
  %======================================================================
+ \section{PEP 322: Reverse Iteration}
  
! A new built-in function, \function{reversed(seq)}, takes a sequence
! and returns an iterator that returns the elements of the sequence 
! in reverse order.  
! 
! \begin{verbatim}
! >>> for i in reversed([1,2,3]):
! ...    print i
! ... 
! 3
! 2
! 1
! \end{verbatim}
! 
! Note that \function{reversed()} only accepts sequences, not arbitrary
! iterators.  If you want to reverse an iterator, convert it to 
! a list or tuple with \function{list()} or \function{tuple()}.
! 
! \begin{verbatim}
! >>> input = open('/etc/passwd', 'r')
! >>> for line in reversed(list(input)):
! ...   print line
! ... 
! root:*:0:0:System Administrator:/var/root:/bin/tcsh
!   ...
! \end{verbatim}
  
  
***************
*** 77,80 ****
--- 102,122 ----
  \code{L.sort(reverse=True)}.
  
+ \item The list type gained a \method{sorted(iterable)} method that
+ returns the elements of the iterable as a sorted list.  It also accepts 
+ the \var{cmp}, \var{key}, and \var{reverse} keyword arguments, same as 
+ the \method{sort()} method.  An  example usage:
+ 
+ \begin{verbatim}
+ >>> L = [9,7,8,3,2,4,1,6,5]
+ >>> list.sorted(L)
+ [1, 2, 3, 4, 5, 6, 7, 8, 9]
+ >>> L
+ [9, 7, 8, 3, 2, 4, 1, 6, 5]
+ >>> 
+ \end{verbatim}
+ 
+ Note that the original list is unchanged; the list returned by
+ \method{sorted()} is a newly-created one.
+ 
  \item The \function{zip()} built-in function and \function{itertools.izip()} now return  an empty list 
    instead of raising a \exception{TypeError} exception if called
***************
*** 114,117 ****
--- 156,162 ----
     supports transparency, this makes it possible to use a transparent background.
     (Contributed by J\"org Lehmann.)
+ 
+ \item The \module{heapq} module is no longer implemented in Python,
+       having been converted into C.
  
  \item The \module{random} module has a new method called \method{getrandbits(N)} 





More information about the Python-checkins mailing list