DEV Community 👩‍💻👨‍💻

Discussion on: Avoid dict overuse in Python

Collapse
spookylukey profile image
Luke Plant

Thanks for the article, I completely agree. For myself, even on very small projects, the benefits of using an explicit class make themselves apparent very quickly. My rule of thumb is that if I know ahead of time what all the keys are, it shouldn't be a dictionary, it should be a class.

With good tools for quickly defining classes, there is no reason not to any more. I tend to use attrs library instead of the standard library dataclass, but it works very similarly, especially if you use auto_attribs=True.