Skip to content

Instantly share code, notes, and snippets.

@superbobry
Created October 21, 2011 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superbobry/1303829 to your computer and use it in GitHub Desktop.
Save superbobry/1303829 to your computer and use it in GitHub Desktop.
>>> map(lambda (x, y): x + y, ([1, 2], [3, 4]))
[3, 7]
>>> map(lambda (x, y): x + y, [xrange(2)])
[1]
>>> def g():
... yield 1
... yield 2
...
>>> map(lambda (x, y): x + y, [g()])
[3]
>>> # ... as long as it yields *exactly* two items
>>> map(lambda (x, y): x + y, [xrange(3)])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
ValueError: too many values to unpack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment