when-of-python / blog

OLD When of Python Blog
https://whenof.python.nz/blog
2 stars 0 forks source link

blog/classy-data-with-dataclasses #11

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Classy Data with Dataclasses | The When of Python Blog

Passing data around can easily become confusing. Dataclasses are a fantastic way of structuring and documenting our data and we should be using them a lot more. They are the only standard keyword-based data structure which can serve both our immutable and our mutable data needs. Maybe we should stop teaching collections.namedtuple and typing.NamedTuple and focus on making dataclasses.dataclasses as idiomatic, familiar, and readable as possible. It would be good to have One Obvious Way of creating keyword data structures.

https://when-of-python.github.io/blog/classy-data-with-dataclasses.html

grantps commented 1 year ago

Oh this is nice! Making dataclass inheritance safe even when using default arguments by having the option of enforcing keywords only (kw_only) in 3.10: Python dataclass inheritance, finally !