[Python-ideas] Allow filter(items)

Haoyi Li haoyi.sg at gmail.com
Wed Aug 7 04:05:10 CEST 2013


> I agree. I don't use filter very often and when I do I always have to
think carefully about the order of the arguments. I'd prefer it if it
were more like sort etc.

OTOH, map filter and reduce all have a nice symmetry in thing(func, list).
I guess the logic is that the sort predicate is optional, and the func for
these other things isn't, but anyway...

Boo for inconsistent argument orders =(

-Haoyi


On Wed, Aug 7, 2013 at 9:55 AM, Shane Green <shane at umbrellacode.com> wrote:

> [item for item in items if item] vs [item for item in items if
> bool(item)]
>
> Isn’t an *optional* predicate function also a very common programming
> pattern?
>
>
>
>
> On Aug 6, 2013, at 4:47 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>
> On 8/6/2013 4:23 AM, Serhiy Storchaka wrote:
>
> 06.08.13 10:34, Chris Angelico написав(ла):
>
> Okay. Sounds like there's already an answer to those who want more
> readability: Just use filter(bool,...). Maybe I'm just not seeing the
> obvious problem with this version?
>
>
> Are `if bool(...)` or `if bool(...) == True` more readable than `if ...`?
>
>
> No and irrelevant. This is simply not a parallel situation.
>
> --
> Terry Jan Reedy
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130807/0418805f/attachment.html>


More information about the Python-ideas mailing list