a small problem

Alex alex at somewhere.round.here
Wed Jan 12 19:46:12 EST 2000


> But suppose I have:
> t = [('foo', 'bar'), ('foo_two', 'bar_two'), ('foo_three', 'bar_three')]
> first_ones = map(lambda s: s[0], t)
> last_ones = map(lambda s: s[1], t)
> 
> How would I do that without lambda's, if this code is in a method?
> Should I nest two functions?

from operator import getitem
first_ones=map(getitem,t,len(t)*[0])

:)

Alex.



More information about the Python-list mailing list