[Python-ideas] Allow filter(items)
Shane Green
shane at umbrellacode.com
Wed Aug 7 23:49:37 CEST 2013
On Aug 7, 2013, at 2:43 PM, Shane Green <shane at umbrellacode.com> wrote:
> On Aug 7, 2013, at 10:20 AM, Terry Reedy <tjreedy at udel.edu> wrote:
>
>> On 8/7/2013 4:55 AM, Serhiy Storchaka wrote:
>>
>>> The default predicate is not "bool". The default is identity function
>>> (lambda x: x).
>>
>> Not really. None means "do not apply *any* predicate function".
>>
>> --
>> Terry Jan Reedy
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>
> Which is the identity function predicate and not bool.
>
> Wrriten as [item for item in items if predicate(item)]
>
> None translates:
> [item for item in items if predicate(item)]
> — into —
> [item for item in items if item]
> — not —
> [item for item in items if bool(item)]
>
> So predicate is defined such that predicate(item) == item, which is the definition of the identity function, not bool.
(sorry for the big text in my lsat response, I’m sitting far away and forgot to shrink it back down…which, incidentally, is also my excuse for anything really stupid I say).
I wanted to add that my answer is basically geared around answering the question, okay, if you had to define this with a predicate, what would the predicate be? I’m not literally saying the identity function is used.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130807/d7860017/attachment.html>
More information about the Python-ideas
mailing list