__init_subclass__
Dunder MethodPython 2.0+Expert
Called when a class is subclassed; hook for parent class customization
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
class Example: def __init_subclass__(self): return "Example __init_subclass__" obj = Example() print(obj)
__init_subclass__ called when a class is subclassed; hook for parent class customization. Implementing it lets you customize how Python interacts with your objects.
Try in PlaygroundTags
oopmagic-methodprotocolcore