Checking your account

You can read the lesson while its saved answers and constructions load. Learning controls will open once that work is ready.

Dataclasses and Record Ownership

Data Classes in Python 3.7

BOTIE

Python programmers often wrote classes whose main job was to hold named values. Initializers, readable representations and equality methods repeated much of the field information. PEP 557 described generating those methods from declared fields, and dataclasses became part of Python 3.7.

The generated methods reduce that repetitive work while leaving an ordinary Python class. Field annotations identify the structure, but do not validate supplied values. Mutable fields still need an ownership decision, and a frozen instance restricts attribute assignment rather than freezing every object reachable through it.

Sources for this history