14 Metaclasses and ABCs
Python developers are well familiar with the mantra, “Everything is an object.” When looking at the class system in Python, however, this becomes a paradox: If everything is an object, then what is a class? The seemingly arcane answer to that question unlocks another powerful tool in the Python toolbox: abstract base classes, which are one way of outlining expected behaviors of a type when using duck typing.
In this chapter, I’ll be digging into metaclasses, abstract base classes, and how you can use them to write more maintainable classes.
Metaclasses
Classes are instances of metaclasses, in the same way that objects ...
Get Dead Simple Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.