Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • In Source code accessible: Correct use of "new style", How is -> B & <- B getting printed. If I comment "super(A, self).__init__()" , then it wont print "->B" & "<- B". & if I comment "super(B, self).__init__()" , then everything remains same. Whats actually happening??? Commented Oct 4, 2020 at 8:28
  • @ShambhavAgrawal As stated in the section you mentioned, the MRO for this example is C -> A -> B -> object. Whenever a call to super() is made, execution is passed up the MRO chain. So super(A, self).__init__() passes off to B.__init__() (which prints "-> B" & "<- B") and super(B, self).__init__() passes off to object.__init__() (which doesn't print anything). Commented Oct 6, 2020 at 18:49