Why does foo = filter(…) return a <filter object>, not a list? [duplicate]
问题 This question already has an answer here: Calling filter returns <filter object at … > [duplicate] 2 answers Working in Python IDLE 3.5.0 shell. From my understanding of the builtin "filter" function it returns either a list, tuple, or string, depending on what you pass into it. So, why does the first assignment below work, but not the second (the '>>>'s are just the interactive Python prompts) >>> def greetings(): return "hello" >>> hesaid = greetings() >>> print(hesaid) hello >>> >>>