Comment on Python classes aren’t always the best solutionparentComments−simonw1yI wish python had a clean way to define types without defining classesdataclasses are pretty much that. They use the class mechanism but they're culturally accepted now as a clean way to build the equivalent of structs.−paulddraper1y^ Agreed.And e.g. you can add dataclasses-json for JSON serializability: https://pypi.org/project/dataclasses-json/−isjustintime1yYes, dataclasses are great. I often use them as a pretty clear and adopted way to handle serialization and deserialization, configs, etc.
Comments
dataclasses are pretty much that. They use the class mechanism but they're culturally accepted now as a clean way to build the equivalent of structs.
^ Agreed.
And e.g. you can add dataclasses-json for JSON serializability: https://pypi.org/project/dataclasses-json/
Yes, dataclasses are great. I often use them as a pretty clear and adopted way to handle serialization and deserialization, configs, etc.