Getting a list of values from a list of dict in python: Without using list comprehension -


i have list of dict example,

[{'id': 1l, 'name': u'library'}, {'id': 2l, 'name': u'arts'}, {'id': 3l, 'name':  u'sports'}] 

now, have retrieve following list dict without using list comprehension

[u'library', u'arts', u'sports'] 

is there way achieve in python? saw many similar questions, answers using list comprehension.

any suggestion appreciated. in advance.

you use itemgetter:

from operator import itemgetter  categories = map(itemgetter('name'), things) 

but list comprehension too. what's wrong list comprehensions?


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -