Re:Don't let dicts spoil your code
by fallingsquirrel on Tuesday October 08, 2024 @11:04PM
(#41784097)
NamedTuples are great, but they let you do too much with the objects. You probably don't want users of your GitHubRepo class to be able to do things like `repo[1]` or `for foo in repo`. Dataclasses have more constrained semantics, so I reach for them by default. In my ideal world they would default to frozen=True, kw_only=True, slots=True, but even without those they're a big improvement.
[ Parent
| on HN ]
There are no comments on this comment yet.