What is `__init_subclass__` in Python and when is it useful?

Python Developer Hard

Python Developer — Hard

What is `__init_subclass__` in Python and when is it useful?

Key points

  • `__init_subclass__` is not automatically called in subclass constructors
  • It is a way for the base class to interact with subclasses during creation
  • This method is useful for customizing subclass behavior without using metaclasses

Ready to go further?

Related questions