On Fri, May 1, 2009 at 1:53 AM, Saurabh <phoneth...@gmail.com> wrote:
> arr = ({'x':'1', 'y':'a'}, {'x':'2', 'y':'b'}, {'x':'3', 'y':'c'})
> print foo(arr, 'y')
> ['a','b','c']
>
> I can write the function foo to return ['a','b','c'].
> Is there some 'automatic'/built-in way to get this in Python ?

from operator import itemgetter
print map(itemgetter("y"), arr)

Cheers,
Chris
-- 
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to