The filter Function

filter(func, s) filters the elements of a sequence

     a = [1,2,3,4,5,6]
     b = filter(lambda x: x < 4, a)  # b = [1,2,3]
  • If func is None, filter() returns all of the elements that evaluate to true.
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 88
July 17, 2000, beazley@cs.uchicago.edu
>>>