returning values of a particular key from a dictionary

Saurabh phonethics at gmail.com
Fri May 1 04:53:33 EDT 2009


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 ?

-- 
Phonethics



More information about the Python-list mailing list