Skip to content

Instantly share code, notes, and snippets.

@oxtopus
Created September 26, 2011 16:38
Show Gist options
  • Save oxtopus/1242678 to your computer and use it in GitHub Desktop.
Save oxtopus/1242678 to your computer and use it in GitHub Desktop.
map(itemgetter(n), iterable) == [i[n] for i in iterable]
>>> 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