Skip to content

Glossary: Python Beyond the Basics

dataclass

Also written: @dataclass, dataclasses, fields, field

A class whose `__init__`, `__repr__` and `__eq__` are written for you by the `@dataclass` decorator from a list of typed fields. Options like `order=True` and `frozen=True` add sorting and immutability.

Where the book teaches it

Related terms

frozen dataclasstype hintdecorator