Conversion from tuple to argument list?

David Bolen db3l at fitlinxx.com
Wed Nov 21 01:45:07 CET 2001


Erik Johnson <ejohnso9 at earthlink.net> writes:

> Chris Liechti wrote:
> 
> > <SNIP>
> >
> > >>> args = range(3)
> >
> > newer python releases:
> > >>> struct.pack("bbb", *args)
> > '\x00\x01\x02'
> >
> 
>       Hmm, I am new to Python. ORA's "Learning Python" & "Programming Python"
> both document the use of '*' for variable argument lists in the function
> definition, but this is the first time I have seen it used in the function
> call. Does this sort of use have a name? Is this documented somewhere?

Thus the preface about "newer python releases".  This feature (and
**kwargs for passing keyword arguments) mirrors the use of the similar
syntax in function formal parameters for accepting normal unnamed and
keyword arguments.  It was added in Python 2.0.

It's mentioned briefly in the What's New document for Python 2.0
(http://www.python.org/2.0/new-python.html).  I'm not actually sure
where it may be documented in the primary set of documentation.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list