β All terms Β· OOP
ABC (Abstract base class)
Inheriting `abc.ABC` + decorating with `@abstractmethod` prevents instantiation until subclasses override every abstract method. Documentation the language enforces.
class Shape(ABC):
@abstractmethod
def area(self): ...Learn this interactively:
Open lesson lesson-145 β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.Dunder methodsDouble-underscore methods that hook into Python syntax: `__add__`, `__len__`, `_β¦InheritanceA class can inherit attributes and methods from a parent class: `class Dog(Animaβ¦