r/learnpython • • Mar 12 '24

Is python OOP the real thing ?

Hello, I'm currently writing a report on a project where I used python with the OOP paradigm and I want to be sure to not talk nonsense in it.

So, here is my question : Is python really fully respecting the OOP paradigm ?

I mean, for exemple when I want to make an abstract class, the concept doesn't really seem to exist. When I write an abstract method, I am obligated to use a decorator and it doesn't even prevent from calling the parent method. So i need to have a default behavior in it...

Also another question : I have seen that only mutable parameters can be updated in the body of a function. Is it specific to python or something generalized to other languages ?

4 Upvotes

35 comments sorted by

View all comments

1

u/[deleted] Mar 12 '24

I don't think OOP means anything anymore, so personally I would not mention this at all.

I don't really know exactly what you find lacking in the class system that needs to be there to be called OO. The only difference between java and python is that you can access any field and new classes can be created in the same file. Otherwise mixing data and functions is totally allowed using the class feature.

The original OO design had classes behave like state machines (like mini virtual computers) that can compute things internally and send messages to each other via an api. This design is terrible, which why no mainstream language does that.

I'm not sure what you mean by abstract class. Perhaps you mean what java might call an interface. Those exist as libraries in interface and typing. The usefulness of which is debatable. Since python is not statically typed, nor are interfaces used in the standard libs, you can't get the real deal from interfaces. For example, you can't just use the sort method by having a Compatible interface. Nor can you implement abstract functions that require an interface over types or classes.

To me, this says that python is not an OO language but does have OO features. But then, this begs the question, is something like Haskell and Rust OO because those do have interfaces and they are enforced even in the standard libs? This comes back to the beginning, what does OOP even mean?