functools.partialcreates an object that behaves like a new function that mimics an old function with some frozen arguments. Therefore, you should call this new function to get the same output:
for x in functools.partial(TestClass().method, 10)():
print x
source
share