[Python-checkins] python/dist/src/Doc/lib libfuncs.tex, 1.157,
1.158 libitertools.tex, 1.25, 1.26 libstdtypes.tex, 1.145, 1.146
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Dec 17 15:43:34 EST 2003
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv9388/Doc/lib
Modified Files:
libfuncs.tex libitertools.tex libstdtypes.tex
Log Message:
Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
Index: libfuncs.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v
retrieving revision 1.157
retrieving revision 1.158
diff -C2 -d -r1.157 -r1.158
*** libfuncs.tex 7 Dec 2003 11:24:03 -0000 1.157
--- libfuncs.tex 17 Dec 2003 20:43:32 -0000 1.158
***************
*** 887,890 ****
--- 887,899 ----
\end{funcdesc}
+ \begin{funcdesc}{sorted(\var{iterable}\optional{, \var{cmp}=None
+ \optional{, \var{key}=None
+ \optional{, \var{reverse}=False}}})}
+ Return a new sorted list from the items in \var{iterable}.
+ The optional arguments \var{cmp}, \var{key}, and \var{reverse}
+ have the same meaning as those for the \method{list.sort()} method.
+ \versionadded{2.4}
+ \end{funcdesc}
+
\begin{funcdesc}{staticmethod}{function}
Return a static method for \var{function}.
Index: libitertools.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** libitertools.tex 7 Dec 2003 13:00:25 -0000 1.25
--- libitertools.tex 17 Dec 2003 20:43:32 -0000 1.26
***************
*** 399,403 ****
>>> from operator import itemgetter
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
! >>> di = list.sorted(d.iteritems(), key=itemgetter(1))
>>> for k, g in groupby(di, key=itemgetter(1)):
... print k, map(itemgetter(0), g)
--- 399,403 ----
>>> from operator import itemgetter
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
! >>> di = sorted(d.iteritems(), key=itemgetter(1))
>>> for k, g in groupby(di, key=itemgetter(1)):
... print k, map(itemgetter(0), g)
Index: libstdtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v
retrieving revision 1.145
retrieving revision 1.146
diff -C2 -d -r1.145 -r1.146
*** libstdtypes.tex 17 Dec 2003 02:49:03 -0000 1.145
--- libstdtypes.tex 17 Dec 2003 20:43:32 -0000 1.146
***************
*** 989,995 ****
\optional{, \var{reverse}=False}}})}
{sort the items of \var{s} in place}{(7), (8), (9), (10)}
- \lineiii{\var{s}.sorted(\var{iterable}\optional{, \var{cmp}=None\optional{, \var{key}=None
- \optional{, \var{reverse}=False}}})}
- {return a new sorted list from the items in \var{iterable}}{(8), (9), (11)}
\end{tableiii}
\indexiv{operations on}{mutable}{sequence}{types}
--- 989,992 ----
***************
*** 1041,1046 ****
the sorted or reversed list.
! \item[(8)] The \method{sort()} and \method{sorted()} methods take optional
! arguments for controlling the comparisons.
\var{cmp} specifies a custom comparison function of two arguments
--- 1038,1043 ----
the sorted or reversed list.
! \item[(8)] The \method{sort()} method takes optional arguments for
! controlling the comparisions.
\var{cmp} specifies a custom comparison function of two arguments
***************
*** 1069,1074 ****
\item[(9)] Starting with Python 2.3, the \method{sort()} method is
! guaranteed to be stable. Starting with Python 2.4, the \method{sorted()}
! method is also guaranteed to be stable. A sort is stable if it does not
change the relative order of elements that compare equal --- this is
helpful for sorting in multiple passes (for example, sort by
--- 1066,1070 ----
\item[(9)] Starting with Python 2.3, the \method{sort()} method is
! guaranteed to be stable. A sort is stable if it guarantees not to
change the relative order of elements that compare equal --- this is
helpful for sorting in multiple passes (for example, sort by
***************
*** 1080,1086 ****
\exception{ValueError} if it can detect that the list has been
mutated during a sort.
-
- \item[(11)] \method{sorted()} is a class method that returns a new list.
- \versionadded{2.4}
\end{description}
--- 1076,1079 ----
More information about the Python-checkins
mailing list