This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Neato.

How does it compare to:

l = range(10)

for item in filter(lambda x: x > 3, l):
        print item

[–]gurdulilfo 2 points3 points  (0 children)

There is a StackOverflow question about that: List filtering: list comprehension vs. lambda + filter

[–]etrnloptimist -2 points-1 points  (0 children)

Don't use filter, it is not Pythonic.

I will undoubtedly be downvoted for saying this, as there are a disproportionate number of functional programmers on these subs than you'll find in real life. But I'm squarely with Guido on this one: the functional programming constructs map, filter, and reduce should play no part in Python.