1 Comment
User's avatar
Pete Bachant's avatar

I've also been guilty of abusing classes in Python in the past, namely using them to write what are effectively procedures. Python classes in particular encourage bad practices, since the `self` keyword becomes a dumping ground for limitless mutable state, and some will be tempted to reduce duplicate code with inheritance. Your recommendation to use data classes and functions is a good one (Pydantic can also be useful in lieu of Python's built-in dataclasses). Use custom data types to model the problem domain, but don't try to do object-oriented programming when an application effectively executes procedures (like a data processing pipeline).

Expand full comment