Python Dataclasses: Eliminating Boilerplate Without Shared-State Bugs
Use @dataclass to generate __init__ and __repr__ automatically, but mutable defaults, frozen instances, and inheritance ordering introduce subtle bugs if you skip the mechanics.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use @dataclass to generate __init__ and __repr__ automatically, but mutable defaults, frozen instances, and inheritance ordering introduce subtle bugs if you skip the mechanics.
Use @dataclass with __post_init__ to validate inputs and compute derived fields after initialization. Learn how to enforce invariants, handle mutable defaults, work with frozen dataclasses, and avoid common pitfalls like shared mutable state and inheritance issues.