Cappy2112 <[EMAIL PROTECTED]> wrote:
>  What does the leading * do?

It causes the list/tuple following the * to be unpacked into function
arguments. Eg

>>> zip(*[(1, 2, 3), (4, 5, 6)])
[(1, 4), (2, 5), (3, 6)]

is the same as

>>> zip((1, 2, 3), (4, 5, 6))
[(1, 4), (2, 5), (3, 6)]

The * should make you think of dereferencing things (eg pointer
de-reference in C).

Its equivalent to the now deprecated apply function which does the
same thing in a more wordy fashion, ie apply the list as parameters to
the function.

>>> apply(zip, [(1, 2, 3), (4, 5, 6)])
[(1, 4), (2, 5), (3, 6)]

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to