other questions have already clarified, that in python3 filter
returns an iterator. to print it, one may use the list function:
odds = filter(lambda x: x>2,[1,2,3,1.1,1.2,1.3,4])
print(list(odds))
this prints correctly:
[3, 4]
however, the execution of list 'consumes' the iterator produced by list. so, if I call again:
print(list(odds))
this prints an empty string. most importantly, if I use the list function to see the iterator, then I cannot use it later in my script (e.g. as an iterator), because it has been consumed/emptied/iterated. is there a way to see the iterator without consuming it or is it like the uncertainty principle in quantum mechanics, that if I observe an iterator I also modify it? I think the answer is no, but I thought it would be useful for other stackoverflowers to know this issue.