According to the documentation on ABCs, I should just have to add a next
method to be able to subclass collections.Iterator
. So, I'm using the following class:
class DummyClass(collections.Iterator):
def next(self):
return 1
However, I get an error when I try to instantiate it:
>>> x = DummyClass()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class DummyClass with abstract methods __next__
I'm guessing that I'm doing something stupid, but I can't figure out what it is. Can anyone shed some light on this? I could add a __next__
method, but I was under the impression that was only for C classes.