2 ms·
I agree with you for the example with a named function P, but as Guido points out, filter predicates are typically simple expression which you don't want to cre
by goto11 8y ago
I agree with you for the example with a named function P, but as Guido points out, filter predicates are typically simple expression which you don't want to create a named function for. So it would be say `filter(lambda x: x < 17, S)` versus `[x for x in S if x < 17]`. I think the second one is nicer even if the repeated x is ugly. Neither is great though. The comprehension syntax assumes filters are accompanied by maps. A filter without a map is a somewhat ugly special-case.
The real issue is the lack of a lambda syntax with a pythonic feel.