Skip to content

Comment on Python classes aren’t always the best solution

Comments

For people who think classes are terrible, can you explain how you would implement the functionality associated with a Pandas DataFrame, without using classes? Did the Pandas developers simply get it wrong when choosing how to build this?

https://pandas.pydata.org/docs/reference/api/pandas.DataFram...

I don't think there are many people that say classes are bad outright. After all, you can write Go code that look identical to code in another language with classes. It's more about misusing OOP and unnecessary amount of abstraction people complain about.

Also, patterns in data science often don't transfer to general programming. Very few data scientists annotate their python types, let alone writing unit tests. Source control of Jupyter notebooks is often non-existent. It's a different way of doing things, and I would exclude numpy/pandas from discussions unless necessary.

To be clear, "You might not need" does not mean "You shouldn't use"

AboutSource Built by g1lg1l

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