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

Pavol Lisy pavol.lisy at gmail.com
Tue Mar 8 15:06:50 EST 2016


2016-03-08 15:17 GMT+01:00, Allan Clark <allan.clark at gmail.com>:
[...]
>     [y for x in numbers if abs(x) as y > 5]
[...]
>     * It would need to be decided whether you allowed multiple 'as'
> expression in the condition, particularly using 'and' or 'or' as in 'if
> f(a) as x > 5 and f(b) as y > 5'

Just small idea not to forget here:

[y+z for x in numbers if abs(x) as y > 5 or x**2 as z>100]

"or" is short-circuit operator so z could be not (well) defined.


More information about the Python-ideas mailing list