[Python-ideas] Adding list.pluck()
cenkalti at gmail.com
Fri Jun 1 23:48:04 CEST 2012
l.pluck('name') is more readable IMO.
On Sat, Jun 2, 2012 at 12:25 AM, Alexandre Zani
<alexandre.zani at gmail.com> wrote:
> What if it's a list of objects instead of a list of dicts? List
> comprehension already makes this easy:
> [i['name'] for i in l]
> On Fri, Jun 1, 2012 at 2:16 PM, Oleg Broytman <phd at phdru.name> wrote:
>> On Sat, Jun 02, 2012 at 12:10:03AM +0300, Cenk Alt?? <cenkalti at gmail.com> wrote:
>>> pluck() is a beautiful function which is in underscore.js library.
>>> Described as "A convenient version of what is perhaps the most common
>>> use-case for map: extracting a list of property values."
>>> What about it implementing for python lists? And maybe for other iterables?
>> Like operator.attrgetter?
>> Oleg Broytman http://phdru.name/ phd at phdru.name
>> Programmers don't die, they just GOSUB without RETURN.
>> Python-ideas mailing list
>> Python-ideas at python.org
> Python-ideas mailing list
> Python-ideas at python.org
More information about the Python-ideas