For python 3, the definition is changed.
From doc
filter(function, iterable)
Construct an iterator from those elements
of iterable for which function returns true. iterable may be either a
sequence, a container which supports iteration, or an iterator. If
function is None, the identity function is assumed, that is, all
elements of iterable that are false are removed.
Example:
>>> filter(lambda x: x in 'hello buddy!', 'hello world')
<filter object at 0x000002ACBEEDCB00> # filter returns object !important
>>> ''.join([i for i in filter(lambda x: x in 'hello buddy!', 'hello world')])
'hello old'
>>> [i for i in filter(lambda n: n % 2, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9})]
[1, 3, 5, 7, 9]