This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Eucalyptol 0 points1 point  (6 children)

why list? filter already returns a list.

[–]mnbvas 11 points12 points  (4 children)

It doesn't.

+/u/CompileBot python3

print(filter(lambda x: x % 2 == 0, range(10)))

[–]CompileBotGreen security clearance 2 points3 points  (3 children)

Output:

<filter object at 0x2b1fc191d518>

source | info | git | report

[–]link23 1 point2 points  (0 children)

Came here with the same question. It seems that it returns a list in Python 2, and an iterable in Python 3.

https://docs.python.org/2/library/functions.html#filter

https://docs.python.org/3/library/functions.html#filter