4 ms·
So, why Python programmers prefer making classes when the language has dictionaries? Bound methods. And yes, if you don't drive it into the ground, inheritanc
by vanusa 5y ago
So, why Python programmers prefer making classes when the language has dictionaries?
Bound methods. And yes, if you don't drive it into the ground, inheritance can be useful, also.
- wheelerof4te 5y agoBoth useful, yes. But consider this: my_instance = SomeClass(args) my_instance.method() vs my_dict = some_mod.thing_new(args) some_mod.function(my_dict, args) These are semantically the same things. If you don't believe me, consider this is the same as above class example: SomeClass.method(my_instance) As for the inheritance, you could theoretically insert the "parent" dictionary inside the "child" dictionary and just create a new module for child "methods". But that would be too convoluted and surely unpythonic. My argument goes against OOP, so I would just ignore inheritance.