Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: