On 6/14/2011 2:37 PM, MRAB wrote:
On 14/06/2011 18:48, Zach Dziura wrote:
[snip]
I just have one quick question. On the line where you have zip(*arr),
what is the * for? Is it like the pointer operator, such as with C? Or
is it exactly the pointer operator?
[snip]
The * in the argument list of a function call unpacks the following
list as arguments for the call, for example, zip(*[0, 1, 2]) becomes
zip(0, 1, 2), so zip(*arr) becomes zip(arr[0], arr[1], ...).
There's also **, which unpacks a dict as keyword arguments.
* and ** in a function call, which distribute arguments,
are essentially the inverse of * and ** in function definitions,
where they say to collect arguments.
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list