← All lessons

Lesson 36 of 62 · about 16 minutes

Dataclasses 🧱

Dataclasses 🧱 Many classes mostly exist to hold data. Writing __init__ , __repr__ and __eq__ by hand for every one of them is repetitive and easy to get wrong. The @dataclass decorator writes them for you from a simple list of fields. Your first dataclass…

This lesson is part of Pythonaut Pro. The first two lessons are free, so you can start there and see how it works.

See the free lessons