Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
SethMLarson
· 4y ago · 0 comments
I'd recommend dataclasses over namedtuples. In almost every case the "iterability" of a namedtuple ends up not being necessary (and can be a footgun!) what you really want is a lightweight namespace with types i.e. dataclasses!
Comments
[–]
teddyh
4y ago
On the other hand, the immutability of a named tuple can be useful.
[–]
Marcan
4y ago
You can set frozen=True to make a dataclass immutable.