3 ms·
There is harmful advice in this article. "Just chill and use a dict or a namedtuple" leads inexorably to buggy code. The advice to use dataclasses is good but.
by pydry 1y ago
There is harmful advice in this article. "Just chill and use a dict or a namedtuple" leads inexorably to buggy code.
The advice to use dataclasses is good but... dataclasses are, um, classes.
- ackfoobar 1y ago> 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.
- hidelooktropic 1y agoI thought readers would understand that an alternative to a class just meant you don't have to create one from scratch. Maybe not.