[Python-checkins] python/dist/src/Doc/tut tut.tex,1.196,1.196.8.1

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Fri Aug 8 17:31:38 EDT 2003


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

Modified Files:
      Tag: release23-maint
	tut.tex 
Log Message:
Explain argument unpacking

Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.196
retrieving revision 1.196.8.1
diff -C2 -d -r1.196 -r1.196.8.1
*** tut.tex	15 Jul 2003 23:16:01 -0000	1.196
--- tut.tex	8 Aug 2003 23:31:35 -0000	1.196.8.1
***************
*** 1578,1581 ****
--- 1578,1599 ----
  
  
+ \subsection{Unpacking Argument Lists \label{unpacking-arguments}}
+ 
+ The reverse situation occurs when the arguments are already in a list
+ or tuple but need to be unpacked for a function call requiring separate
+ positional arguments.  For instance, the built-in \function{range()}
+ function expects separate \var{start} and \var{stop} arguments.  If they
+ are not available separately, write the function call with the 
+ \code{*}-operator to unpack the arguments out of a list or tuple:
+ 
+ \begin{verbatim}
+ >>> range(3, 6)             # normal call with separate arguments
+ [3, 4, 5]
+ >>> args = [3, 6]
+ >>> range(*args)            # call with arguments unpacked from a list
+ [3, 4, 5]
+ \end{verbatim}
+ 
+ 
  \subsection{Lambda Forms \label{lambda}}
  





More information about the Python-checkins mailing list