This is a kind of additional question regarding a very popular questionsuper( ) . The question was basically “Why should I use, super( )” and the answer was “Because you don't need to reference the parent class, which may be nice.”
My question is: why is it good in the world? What happened to "Explicit is better than implied?" Let's say I read some other developer code, and I see:
class Foo(Bar, Baz):
def my_method(self):
super(Foo, self).who_knows( )
Now I need to dig through the documents on Barand Bazand all their parent classes to the tree to find out where it comes from and where who_knows( ). I also need a perfect understanding of the resolution order of the method in order to find out which one is who_knows( )actually being called.
Now look at the same code without super( ):
class Foo(Bar, Baz):
def my_method(self):
Baz.who_knows(self)
Much clearer, no need to guess or understand the MRO.
I do not raise this issue to start a debate or philosophical discussion. I just hope that someone can show me some very clear examples in which an implicit character is super( )really desirable, because, to be honest, I do not see it.
source
share