# Dataclass

*noun*

say it: **“DAY-tuh-klas”** **/ˈdeɪtəˌklæs/**

A Python class made mainly to hold data: the @dataclass decorator writes \_\_init\_\_, printing and comparing for you from the fields you list.

## What is a **dataclass**?

A **dataclass** is a class mainly for holding data. The `@dataclass` decorator writes `__init__`, printing and comparing for you from the fields you list.

```python
from dataclasses import dataclass

@dataclass
class Product:
    name: str
    price: float

lamp = Product("Lamp", 25.0)
print(lamp)  # Product(name='Lamp', price=25.0)
```

## In a sentence

- “Printing a **dataclass** shows its fields, such as Product(name='Lamp', price=25.0).”
- “Product is a **dataclass** with a name and a price.”

Level: Freelancer · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=4)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/dataclass
