inverse of the zip function

Diez B. Roggisch deets_noospaam at web.de
Tue Jul 29 19:30:13 EDT 2003


Raymond Hettinger wrote:

>> >> In other words, the the inverse of the built-in zip function?
>> >
>> > When used with the * operator, zip() is its own inverse:
> There is no special extension to zip().
> It just happens to be one of those functions
> like int.__neg__() that is closely related to
> its own inverse.
> 
> * or apply() serve only to break a list into
> individual arguments.  So, transpose() can
> be defined like this:

I understand why it works as inverse when *<list> creates a argument list of
list element. But don't understand why * works that way in this context.
Does ** do this for maps and keywordargs, too? Hey, this is python - lets
try:
>>> def foo(a=None, b=None):
...   pass
...
>>> foo(a=10, b=20)
>>> foo(**{'a':10, 'b':20})
>>>

Coooool. Where is that documented? Never stumbled across it so far!

Diez




More information about the Python-list mailing list