(Using Python 3.1)
I know this question has been asked many times for the general question of testing if iterator is empty; obviously, there\'s no neat solution to t
If you just want to check if the return of filter is empty, you might do (Python3)
len(list(filter(lambda e : e == 2, [1,2,3])))
But notice, hence filter is a generator if you this test twice, second time, you will receive a diferent result:
len(list(filter(lambda e : e == 2, [1,2,3])))
len(list(filter(lambda e : e == 2, [1,2,3])))
>>> 1
>>> 1
But:
f = filter(lambda e : e == 2, [1,2,3])
len(list(f))
len(list(f))
>>> 1
>>> 0