Python Metaclasses and Metaprogramming
Understanding Python metaclasses | ionel’s codelog

TL;DR
All classes come from metaclasses. type is the default metaclass, and is a metaclass of itself.

Some practical examples of metaclass metaprogramming is
1. by using decorators to modify methods or functions
2. prevent subclassing
3. to enforce interfaces (though achievable via inheritance as well)

Alternatives to Metaclasses

  1. Simple inheritance: This may work if the enforcement that you want to achieve does not require metaprogramming (e.g. modifying annotation at definition time)
  2. Decorators
    • Requires a user to explicitly call it when they want to use it.
    • Can’t be enforced across the board. That may or may not be the intended behaviour.