On Thu, 22 Jan 2009 22:04:15 -0000, Tobiah <t...@tobiah.org> wrote:

Although it's trivial to program, I wondered whether
there was a builtin or particularly concise way to
express this idea:

a = [(1, 2), (3, 4), (5, 6)]
field[a, 2]
[2, 4, 6]

where field() is some made up function.

If field() already exists, there's always a list
comprehension: [field(l) for l in a]

If you want that specific list:

[l[1] for l in a]
[2, 4, 6]

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to