[Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.63,1.64

akuchling@users.sourceforge.net akuchling@users.sourceforge.net
2002年11月13日 05:24:43 -0800


Update of /cvsroot/python/python/dist/src/Doc/whatsnew
In directory usw-pr-cvs1:/tmp/cvs-serv27760
Modified Files:
	whatsnew23.tex 
Log Message:
Fill out the 'Porting' section
Add random.sample()
Index: whatsnew23.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -d -r1.63 -r1.64
*** whatsnew23.tex	5 Nov 2002 00:26:33 -0000	1.63
--- whatsnew23.tex	13 Nov 2002 13:24:41 -0000	1.64
***************
*** 944,948 ****
 information about the priority queue data structure.)
 
! The Python \module{heapq} module provides \function{heappush()} and
 \function{heappop()} functions for adding and removing items while
 maintaining the heap property on top of some other mutable Python
--- 944,948 ----
 information about the priority queue data structure.)
 
! The \module{heapq} module provides \function{heappush()} and
 \function{heappop()} functions for adding and removing items while
 maintaining the heap property on top of some other mutable Python
***************
*** 1001,1004 ****
--- 1001,1029 ----
 will enable buffering.
 
+ \item The \function{sample(\var{population}, \var{k})} function was
+ added to the \module{random} module. \var{population} is a sequence
+ containing the elements of a population, and \function{sample()}
+ chooses \var{k} elements from the population without replacing chosen
+ elements. \var{k} can be any value up to \code{len(\var{population})}.
+ For example:
+ 
+ \begin{verbatim}
+ >>> pop = range(6) ; pop
+ [0, 1, 2, 3, 4, 5]
+ >>> random.sample(pop, 3) # Choose three elements
+ [0, 4, 3]
+ >>> random.sample(pop, 6) # Choose all six elements
+ [4, 5, 0, 3, 2, 1]
+ >>> random.sample(pop, 6) # Choose six again
+ [4, 2, 3, 0, 5, 1]
+ >>> random.sample(pop, 7) # Can't choose more than six
+ Traceback (most recent call last):
+ File ``<stdin>'', line 1, in ?
+ File ``/home/amk/src/sf/python/dist/src/Lib/random.py'', line 396, in sample
+ raise ValueError, ``sample larger than population''
+ ValueError: sample larger than population
+ >>>
+ \end{verbatim}
+ 
 \item The \module{readline} module also gained a number of new
 functions: \function{get_history_item()},
***************
*** 1339,1343 ****
 \section{Porting to Python 2.3}
 
! XXX write this
 
 
--- 1364,1403 ----
 \section{Porting to Python 2.3}
 
! This section lists changes that may actually require changes to your code:
! 
! \begin{itemize}
! 
! \item \keyword{yield} is now always a keyword; if it's used as a
! variable name in your code, a different name must be chosen.
! 
! \item You can no longer disable assertions by assigning to \code{__debug__}.
! 
! \item Using \code{None} as a variable name will now result in a
! \exception{SyntaxWarning} warning. 
! 
! \item Names of extension types defined by the modules included with
! Python now contain the module and a \samp{.} in front of the type
! name. 
! 
! \item For strings \var{X} and \var{Y}, \code{\var{X} in \var{Y}} now works
! if \var{X} is more than one character long.
! 
! \item The Distutils \function{setup()} function has gained various new
! keyword arguments such as \samp{depends}. Old versions of the
! Distutils will abort if passed unknown keywords. The fix is to check
! for the presence of the new \function{get_distutil_options()} function
! in your \file{setup.py} if you want to only support the new keywords
! with a version of the Distutils that supports them:
! 
! \begin{verbatim}
! from distutils import core
! 
! kw = {'sources': 'foo.c', ...}
! if hasattr(core, 'get_distutil_options'):
! kw['depends'] = ['foo.h']
! ext = Extension(**kw) 
! \end{verbatim}
! 
! \end{itemize}
 
 

AltStyle によって変換されたページ (->オリジナル) /