[Python-ideas] Adding list.pluck()

Calvin Spealman ironfroggy at gmail.com
Sat Jun 2 18:28:52 CEST 2012

On Fri, Jun 1, 2012 at 5:10 PM, Cenk Altı <cenkalti at gmail.com> wrote:
> Hello All,
> 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."
> http://documentcloud.github.com/underscore/#pluck
> What about it implementing for python lists? And maybe for other iterables?

This is a case where a simple list comprehension or generator
expression would be a lot easier to understand than remembering what a
rarely used method name does. Also, it couples two distinct
interfaces, iterables and mappings, in a way that is generally frowned
upon in Python.

> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

Read my blog! I depend on your acceptance of my opinion! I am interesting!
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy

More information about the Python-ideas mailing list