Skip to content

Comment on Python classes aren’t always the best solutionparent

Comments

I wish python had a clean way to define types without defining classes

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.