If Inheritance is so bad, why does everyone use it?
Alloy Workshop There are still two slots available for the alloy workshop! I've been hard at work adding a bunch of teaching innovations to the class, which...
Stay updated with breaking news from Abstract Base Classes. Get real-time updates on events, politics, business, and more. Visit us for reliable news and exclusive interviews.
Alloy Workshop There are still two slots available for the alloy workshop! I've been hard at work adding a bunch of teaching innovations to the class, which...
Let's make the CPython team regret adding pattern matching to Python!
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 b...