returns a proxy object that delegates method calls to a parent or
sibling class of type.
This proxy
is an object that acts as the method-calling portion of the parent class. It is not the class itself; rather, it's just enough information so that you can use it to call the parent class methods.
If you call __init__()
, you get your own, local, sub-class __init__
function. When you call super()
, you get that proxy object, which will redirect you to the parent-class methods. Thus, when you call super().__init__()
, that proxy redirects the call to the parent-class __init__
method.
Similarly, if you were to call super().foo
, you would get the foo
method from the parent class -- again, re-routed by that proxy.
Is that clear to you?
RESPONSES TO OP COMMENTS
But that must mean that this proxy object is being passed to
init() when running super().init() right?
Wrong. The proxy object is like a package name, such as calling math.sqrt(). You're not passing math to sqrt, you're using it to denote which sqrt you're using. If you wanted to pass the proxy to init, the call would be init(super()). That call would be semantically ridiculous, of course.
When we have to actually pass in self which is the sc object in my example.
No, you are not passing in sc
; that is the result of the object creation call (internal method __new__
), which includes an invocation of init
. For __init__
, the self
object is a new item created for you by the Python run-time system. For most class methods, that first argument (called self
out of convention, this
in other languages) is the object that invoked the method.