[Python-ideas] Allow filter(items)
Shane Green
shane at umbrellacode.com
Wed Aug 7 04:46:36 CEST 2013
It seems kind of like there should be a filtered operation like there is a sorted one.
(and why not have a list.filter(predicate=None) to perform in place filtering for that matter?)
<I’m expecting a deluge of obvious reasons those were very stupid questions to ask>
On Aug 6, 2013, at 7:05 PM, Haoyi Li <haoyi.sg at gmail.com> wrote:
> > 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/20130806/7ead9d31/attachment-0001.html>
More information about the Python-ideas
mailing list