Help With filter().
aleaxit at yahoo.com
Thu Jul 12 10:48:11 CEST 2001
"EricIDLE" <grayson-wilson at home.com> wrote in message
news:XA537.678643$166.13965187 at news1.rdc1.bc.home.com...
> What does filter do? I don't understand when I read it other places.
Would you understand the following pure Python function...:
return [item for item in sequence if function(item)]
or its more verbose equivalent...:
def filter2(function, sequence):
result = 
for item in sequence:
If you understand this, it's very easy to explain the
semantics of builtin filter by difference from those
of these pure-Python filter1 and filter2 -- the
differences are not many, nor are they complex.
If you don't understand these pure-Python functions,
then we'd better focus on this, and wait for filter
when you have a better grasp of fundamentals...?
More information about the Python-list