4 ms·
We always use dataclasses with frozen=True to make them immutable.
by lysecret 4y ago
We always use dataclasses with frozen=True to make them immutable.
- half0wl 4y agoSame. I treat them as immutable DTOs [0], or "value objects" if you will instead of "just a plain class". An unfortunate drawback is that not everyone is familiar with the concept of immutability, especially in the world of Python. It can also be confusing to explain how "frozen dataclasses are not actually the Python classes you know" :-/ [0] https://en.wikipedia.org/wiki/Data_transfer_object https://en.wikipedia.org/wiki/Data_transfer_object