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

22

u/crashfrog02 Mar 12 '24

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 ?

How would you “update” a value that is immutable and therefore can’t change?

4

u/MonsieurBouclier Mar 12 '24

Sorry I just took the term without thinking about it. I will reformulate : I have seen that only parameters such as list or dictionaries can be updated in the body of a function. Is it specific to python or something generalized to other languages ?

8

u/notacanuckskibum Mar 12 '24

That distinction, simple immutable data types like integer, and complex mutable types like list is specific to Python. Other languages have different techniques for controlling whether parameters to a function can be changed by the function. It does tend to be language specific.

2

u/MonsieurBouclier Mar 12 '24

Thank you for the clear response. 👍

1

u/dogweather Mar 12 '24

That’s common. Not a great coding practice to do it, but it’s a common semantic implementation

1

u/DuckDatum Mar 12 '24 edited Jun 18 '24

screw memory cheerful telephone offbeat cable quaint rich enjoy distinct

This post was mass deleted and anonymized with Redact

-1

u/crashfrog02 Mar 12 '24

But, my response is the same question. If a value is immutable, how could it be updated? It follows from that that the only values that could be updated - anywhere - are the mutable ones.