Possible duplicate:
Why should I specify my own class when using the super () function, and is there any way around it?
I read this book - "Core Python Programming" , and I really found it very beautiful, I would say. But I was embarrassed at some point when I was studying the topic of Inheritance.
The book said somewhere that we can use super() to call the super class method , which will find the base class method for us, and we donβt need to explicitly skip self , as we do without super.
Here's an example code: -
# Invoking super class method without super() .. Need to pass `self` as argument class Child(Parent): def foo(self): Parent.foo(self)
My question is why should we pass the classname to super() call .. Since the class name can be inferred from the class from which super is called.
So, since super () is called from class Child , the class name must be implicit. So why do we need this?
* EDIT: - Providing Child as a super () parameter does not make sense, because it does not give any information .. We could use super(self) .. And the method would be found in superclasses in the order in which they are indicated inside brackets.
source share