Search code examples
pythonabstractterminologymixins

Python abstract base classes, difference between a mixin & abstract method


The table below displays various abstract base classes that are prevalent throughout Python. However, I am uncertain about their specific usage in this context.

Can you explain the distinction between the 'Abstract Methods' column and the 'Mixin Methods' column? Are the methods in one column optional to implement and those in the other column mandatory?

(Below Image) Official Python Reference - Abstract Base Classes for Containers


enter image description here


Solution

  • Anything in the Abstract Methods column, you have to implement yourself. The ABC provides default implementations of the methods in the Mixin Methods column, implemented in terms of the methods you have to write.