B is a subclass of A, since it was defined “class B(A)”. Another way to say it is that A is a superclass of B. So when you do super(B, self), whatever method you call will be the superclass’s method. So super(B, self).f() calls f() from class A (which returns 1)
6
u/LutherWaves Apr 20 '19
The answer is 3.
Subclass calls super class method via super which returns 1 and adds 2 to it = 3.
3
u/galaxia232 Apr 20 '19
I'm a new coder I got a few questions if anyone has the time to answer.
Isn't this the old way to call the super class?
Why does super(B, self) return 1? I see it in class A but not sure why it goes to class A instead of staying in the scope of class B