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

Koos Zevenhoven k7hoven at gmail.com
Tue Mar 8 15:30:46 EST 2016


On Tue, Mar 8, 2016 at 4:17 PM, Allan Clark <allan.clark at gmail.com> wrote:
> tl;dr What is support like for adding an 'as' clause to comprehension
> syntax? In order to allow map-then-filter, it might look like something
> this:
>
>     [y for x in numbers if abs(x) as y > 5]
>
< [...]

How about this (at least it reads quite nicely in English):

[abs(x) for x in numbers if > 5]

-- Koos


More information about the Python-ideas mailing list