AI engineering glossary · Python advanced

What is dataclass?

Dataclass (also called @dataclass): A class decorated with @dataclass that automatically generates __init__, __repr__ and __eq__ from annotated fields. It removes boilerplate for classes that mainly hold data, such as configuration records. It is part of the standard library from Python 3.7 onward.

Level: intermediateTopic: Python advanced

Dataclass: an example

@dataclass class Config: lr: float = 0.001; epochs: int = 10 then Config(epochs=5) works with no hand-written __init__.

Related terms

More Python advanced terms

Where you learn it

Dataclass is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.