Created
October 21, 2011 13:16
-
-
Save superbobry/1303829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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