Skip to content

Comment on Python classes aren’t always the best solution

Comments

Data classes and enums are the move, IMO, in python, to address the considerations of the article. Enums in particular have room for improvement, but I think they're good enough. (To use in place of common python patterns like strings for choices, or sets of booleans)

This. You can get very far with just dataclasses, enums, and functions. I use dataclasses like I would use structs in C or go.

There’s also pyrsistent for immutable data structures with some nice methods for working with them.

AboutSource Built by g1lg1l

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