>>> n = [1,2,3,4]
>>> filter(lambda x:x>3,n)
>>> len(filter(lambda x:x>3,n))
Traceback
This is an old question, but I think this question needs an answer using the map-reduce ideology. So here:
from functools import reduce
def ilen(iterable):
return reduce(lambda sum, element: sum + 1, iterable, 0)
ilen(filter(lambda x: x > 3, n))
This is especially good if n
doesn't fit in the computer memory.