Skip to main content

← All terms Β· OOP

Dunder methods

Double-underscore methods that hook into Python syntax: `__add__`, `__len__`, `__repr__`. Make your objects feel native.

Learn this interactively:

Open lesson lesson-90 β†’

Related β€” OOP

ClassA blueprint for objects. Created with `class Foo:`. Defines attributes + methods…InstanceA specific object built from a class. `dog = Dog()` makes one instance of `Dog`.selfThe current instance, passed implicitly as the first argument to methods. By con…__init__The constructor β€” runs when you call the class. Used to set instance attributes.InheritanceA class can inherit attributes and methods from a parent class: `class Dog(Anima…DataclassDecorator (`@dataclass`) that auto-generates `__init__`, `__repr__`, and `__eq__…