I am in a very strange situation. I know I can use a method class as a generator as I have done it before. In this other question Can a method within a class be generator? someone asks for the same thing and they say that yes, it can be done.
However, I get an error when I try it. Here is a minimal example:
class SomeClass(object):
def first_ten(self):
for i in range(10):
yield i
a = SomeClass();
next(a.first_ten)
'method' object is not an iterator
why? How is this possible? Thank you edited: fixed code indentation