dataclass

A class decorated with @dataclass from the dataclasses module, which writes __init__, __repr__ and __eq__ for you from a list of annotated fields.

In more detail

It suits plain data records. frozen=True makes instances immutable and hashable.

Example

from dataclasses import dataclass

@dataclass
class Point:
    x: float
    y: float

Related terms

Taught in

References