Python Negatypes • Hillel Wayne : vimarsana.com

Python Negatypes • Hillel Wayne
Back in 2007 Python added Abstract Base Classes, which were intended to be used as interfaces:
from abc import ABC class AbstractIterable(ABC): @abstractmethod def iter (self): while False: yield None def get iterator(self): return self. iter () ABCs were added to strengthen the duck typing a little. If you inherited AbstractIterable, then everybody knew you had an implemented iter method, and could handle that appropriately.
Unsurprisingly, this idea never caught on. People instead prefered “better ask forgiveness than permission” and wrapped calls to iter in a try block.
from abc import ABC class AbstractIterable(ABC): @abstractmethod def iter (self): while False: yield None def get iterator(self): return self. iter () ABCs were added to strengthen the duck typing a little. If you inherited AbstractIterable, then everybody knew you had an implemented iter method, and could handle that appropriately.
Unsurprisingly, this idea never caught on. People instead prefered “better ask forgiveness than permission” and wrapped calls to iter in a try block.