我正在尝试执行以下操作:
import functools
class TestClass():
def method(self, n):
for i in xrange(n):
yield i
# This works
for x in TestClass().method(10):
print x
# This gets a TypeError: functools.partial object not iterable
for x in functools.partial(TestClass().method, 10):
print x
那里有什么问题?