Skip to content

Comment on Python classes aren’t always the best solutionparent

Comments

dataclasses are, um, classes

So is the case when you use `namedtuple`, which creates a new class. This is not an interesting gotcha.

Classes (the Python language construct) are how you implement records (the language-neutral concept) in Python.

It's ironic that the "There Is Only One Way to Do It" language has multiple bad ways to implement records though.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.