[Python-ideas] FW: Map-then-filter in comprehensions

Rob Cliffe rob.cliffe at btinternet.com
Thu Mar 10 08:40:00 EST 2016



On 10/03/2016 13:11, Koos Zevenhoven wrote:
> On Wed, Mar 9, 2016 at 12:10 AM, Mark Mollineaux
> <bufordsharkley at gmail.com> wrote:
> [...]
>
>> Also, Koos's offering above:
>>
>>> [abs(x) for x in numbers if > 5]
>> Is also very nice, but I don't like it when the filtering is:
>>
>> [abs(x) for x in numbers if]
>>
> [snip]
>
>
> [foo(x) for x in things if not None]
>
>
>
[foo(x) for x in things if *is* not None]    # What you wrote is already 
valid syntax, equivalent to [foo(x) for x in things]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160310/cdbace36/attachment-0001.html>


More information about the Python-ideas mailing list