March 2003
Intermediate to advanced
656 pages
39h 30m
English
filter
filter(func,seq)
Constructs a list from those elements of
seq for which
func is true.
func can be any callable object that
accepts a single argument or None.
seq must be a sequence, iterator, or other
iterable object. When func is a callable
object, filter calls
func on each item of
seq and returns the list of items for
which func’s result is
true, like this:
[itemforiteminseqiffunc(item)]
When seq is a string or tuple,
filter’s result is also a string
or tuple, rather than a list. When func is
None, filter tests for true
items like this:
[itemforiteminseqifitem]
Read now
Unlock full access