[Python-ideas] Adding list.pluck()
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."
> 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
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