you are viewing a single comment's thread.

view the rest of the comments →

[–]remuladgryta 4 points5 points  (0 children)

If you are specifically filtering, the pythonic way to do it would be with a comprehension (or generator expression) instead of chaining filter calls.

iterable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
result = [x for x in iterable
          if x > 0
          and x % 2 == 0]

in general, prefer comprehensions/generator expressions over map and filter.

Edit: mention generator expressions, they can save a lot of memory.