Advanced Python
Q79 / 101

What is a Python dataclass (@dataclass decorator) and what does it generate?

Correct! Well done.

Incorrect.

The correct answer is B) A class decorator that auto-generates __init__, __repr__, and optionally __eq__, __lt__, __hash__, and __frozen__ based on field annotations

B

Correct Answer

A class decorator that auto-generates __init__, __repr__, and optionally __eq__, __lt__, __hash__, and __frozen__ based on field annotations

Explanation

@dataclass(eq=True, order=False, frozen=False) generates common dunder methods from annotated fields, reducing boilerplate while remaining a regular class.

Progress
79/101