[Python-checkins]
python/dist/src/Doc/whatsnew whatsnew24.tex, 1.20, 1.21
akuchling at users.sourceforge.net
akuchling at users.sourceforge.net
Thu Dec 18 08:28:15 EST 2003
Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory sc8-pr-cvs1:/tmp/cvs-serv8085
Modified Files:
whatsnew24.tex
Log Message:
Add various items
Index: whatsnew24.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** whatsnew24.tex 17 Dec 2003 20:43:32 -0000 1.20
--- whatsnew24.tex 18 Dec 2003 13:28:13 -0000 1.21
***************
*** 21,29 ****
This article doesn't attempt to provide a complete specification of
the new features, but instead provides a convenient overview. For
! full details, you should refer to the documentation for Python 2.4.
! % add hyperlink when the documentation becomes available online.
If you want to understand the complete implementation and design
rationale, refer to the PEP for a particular new feature.
%======================================================================
\section{PEP 218: Built-In Set Objects}
--- 21,31 ----
This article doesn't attempt to provide a complete specification of
the new features, but instead provides a convenient overview. For
! full details, you should refer to the documentation for Python 2.4,
! such as the \citetitle[../lib/lib.html]{Python Library Reference} and
! the \citetitle[../ref/ref.html]{Python Reference Manual}.
If you want to understand the complete implementation and design
rationale, refer to the PEP for a particular new feature.
+
%======================================================================
\section{PEP 218: Built-In Set Objects}
***************
*** 68,71 ****
--- 70,75 ----
like \method{add()} and \method{remove()} which could alter its contents.
+ % XXX what happens to the sets module?
+
\begin{seealso}
\seepep{218}{Adding a Built-In Set Object Type}{Originally proposed by
***************
*** 74,77 ****
--- 78,86 ----
%======================================================================
+ \section{PEP 237: Unifying Long Integers and Integers}
+
+ XXX write this.
+
+ %======================================================================
\section{PEP 322: Reverse Iteration}
***************
*** 123,126 ****
--- 132,145 ----
fill character other than a space.
+ \item Strings also gained an \method{rsplit()} method that
+ works like the \method{split()} method but splits from the end of the string.
+
+ \begin{verbatim}
+ >>> 'a b c'.split(None, 1)
+ ['a', 'b c']
+ >>> 'a b c'.rsplit(None, 1)
+ ['a b', 'c']
+ \end{verbatim}
+
\item The \method{sort()} method of lists gained three keyword
arguments, \var{cmp}, \var{key}, and \var{reverse}. These arguments
***************
*** 178,182 ****
people with the same age are in name-sorted order.
! \item There is a new builtin function \function{sorted(iterable)} that works
like the in-place \method{list.sort()} method but has been made suitable
for use in expressions. The differences are:
--- 197,201 ----
people with the same age are in name-sorted order.
! \item There is a new built-in function \function{sorted(iterable)} that works
like the in-place \method{list.sort()} method but has been made suitable
for use in expressions. The differences are:
***************
*** 210,214 ****
\end{verbatim}
-
\item The \function{zip()} built-in function and \function{itertools.izip()}
now return an empty list instead of raising a \exception{TypeError}
--- 229,232 ----
***************
*** 313,319 ****
--- 331,375 ----
\end{verbatim}
+ \item \module{itertools} also gained a function named \function{tee(\var{iterator}, \var{N})} that returns \var{N} independent iterators
+ that replicate \var{iterator}. If \var{N} is omitted, the default is
+ 2.
+
+ \begin{verbatim}
+ >>> L = [1,2,3]
+ >>> i1, i2 = itertools.tee(L)
+ >>> i1,i2
+ (<itertools.tee object at 0x402c2080>, <itertools.tee object at 0x402c2090>)
+ >>> list(i1)
+ [1, 2, 3]
+ >>> list(i2)
+ [1, 2, 3]
+ >\end{verbatim}
+
+ Note that \function{tee()} has to keep copies of the values returned
+ by the iterator; in the worst case it may need to keep all of them.
+ This should therefore be used carefully if \var{iterator}
+ returns a very large stream of results.
+
\item A new \function{getsid()} function was added to the
\module{posix} module that underlies the \module{os} module.
(Contributed by J. Raynor.)
+
+ \item The \module{operator} module gained two new functions,
+ \function{attrgetter(\var{attr})} and \function{itemgetter(\var{index})}.
+ Both functions return callables that take a single argument and return
+ the corresponding attribute or item; these callables are handy for use
+ with \function{map()} or \function{list.sort()}. For example, here's a simple
+ us
+
+ \begin{verbatim}
+ >>> L = [('c', 2), ('d', 1), ('a', '4'), ('b', 3)]
+ >>> map(operator.itemgetter(0), L)
+ ['c', 'd', 'a', 'b']
+ >>> map(operator.itemgetter(1), L)
+ [2, 1, '4', 3]
+ >>> L.sort(key=operator.itemgetter(1)) # Sort list by second item in tuples
+ >>> L
+ [('d', 1), ('c', 2), ('b', 3), ('a', '4')]
+ \end{verbatim}
\item The \module{random} module has a new method called \method{getrandbits(N)}
More information about the Python-checkins
mailing list