We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.


filter(function, sequence) => list

Constructs a list from those elements of a sequence for which the function returns true. The sequence argument may be either a sequence, a container which supports iteration, or an iterator. If sequence is a string or a tuple, the result also has that type; otherwise it is always a list. If function is None, the identity function is assumed, that is, all elements of sequence that are false (zero or empty) are removed.

Note that filter(function, sequence) is equivalent to the list comprehension [item for item in sequence if function(item)] if function is not None and [item for item in sequence if item] if function is None.