Python · Lesson 12.6 · Pro
dataclasses
Write simple data-holding classes in a few lines, with printing and comparing built in.
In this lesson
- @dataclass writes __init__ for you
- Defaults and methods
- Lists need field(default_factory=...)
- Sortable and frozen
Go Pro to read this lesson
Pro unlocks every lesson and practice problem in SQL, Python, pandas and NumPy, with answers and step-by-step explanations.