OOP & Data Classes
Classes, inheritance, and the @dataclass shortcut for the common case of a class that's mostly just data.
Core OOP mechanics
Python classes support single and multiple inheritance, with super() to call a parent's method. Every instance method implicitly takes self; @classmethod takes cls instead (operates on the class, not an instance); @staticmethod takes neither (a plain function namespaced under the class).
Dataclasses
Writing __init__, __repr__, and __eq__ by hand for a class that's mostly fields is repetitive. @dataclass generates all three from type-annotated field declarations:
@dataclass
class Point:
x: int
y: int
gives you a working constructor, a readable repr, and value-based equality for free.
When to reach for which
Use a plain class when behavior (methods) is the point. Use a dataclass when the class is primarily a structured bundle of fields — the common case for request/response objects, configuration, and simple domain models.
Prerequisite
Assumes comfort with the built-in containers, since dataclass fields are typically typed as list, dict, or other core types.
