4 ms·
Use a named tuple. This way, you can turn it into a class if it ever becomes necessary without changing any other code.
by teddyh 5y ago
Use a named tuple. This way, you can turn it into a class if it ever becomes necessary without changing any other code.
- SethMLarson 5y agoI'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!