Created
September 26, 2011 16:38
-
-
Save oxtopus/1242678 to your computer and use it in GitHub Desktop.
map(itemgetter(n), iterable) == [i[n] for i in iterable]
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
>>> from operator import itemgetter | |
>>> iterable=[('foo', 'bar', 'baz'), ('apple', 'banana', 'orange')] | |
>>> [i[1] for i in foo] | |
['bar', 'banana'] | |
>>> map(itemgetter(1),foo) | |
['bar', 'banana'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment