The voodoo of zip(*someList)

Jacek Generowicz jacek.generowicz at cern.ch
Mon Aug 30 04:23:21 EDT 2004


mdrop1 at yahoo.com (Message Drop Box) writes:

> How (and why) does zip(*someList) work? 

[...]

> I've never seen the star '*' outside of function/method definitions

It can also be used in function invocations, where it means pretty
much the reverse of what it means in function definitions.

In a parameter list "*foo" means "collect remaining positional
arguments into a sequence (tuple) called 'foo'". In an argument list,
it means "take the sequence 'foo' and expand it into a set of
positional arguments".

You can "reverse" the **kwds syntax in the same way too.

> and I've looked in the Python documentation without success.

Try page 39 of the Python Reference Manual.



More information about the Python-list mailing list