Re:Attrs – the Python library everyone needs (2016)
by progval on Saturday December 25, 2021 @05:55AM
(#29682187)
FWIW, you can also add type annotations for namedtuples, with a syntax similar to data classes: https://docs.python.org/3/library/typing.html#typing.NamedTu...
You can even type dictionaries this way: https://docs.python.org/3/library/typing.html#typing.TypedDi...
Comparatively named tuples are an older language feature which essentially allow you to define named accessors for tuple elements. IIRC, these days you can also define type annotations for them.
Their use case essentially overlap. Personally I much prefer data classes.