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

2

u/yvrelna Mar 12 '24

Every language has slightly different conception of OOP, and every programmers also has slightly different features that they want in their OOP language.

Python's object system sits squarely in one of the stronger OOP language. It has all the features you associate with OOP, everything in Python is an object.

One thing it doesn't do, is force OOP on everything. Python is a multiparadigm language. You can mix and match OOP, imperative, and functional approaches, depending on what the situation calls for. 

A weaker variant of OOP is prototype-based language like JavaScript. Python clearly has stronger OOP than those variants. 

A stronger level of OOP is like Java with objects having access protections, comprehensive built-in support for interfaces and abstract classes, but not everyone agrees that any of those features are even necessary for OOP.

But the original OOP, as it was originally conceived weren't even talking about any of these. The original OOP as it was in Smalltalk is about object actors passing messages to each other. Most modern languages simulates that with imperative function calls, but also they are not really. 

Async programming with a bunch of coroutines communicating with one another via messages resembles a lot of that original OOP, but nobody really calls async programming OOP.