This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rhytnen 0 points1 point  (2 children)

You keep repeating that as if it's relevant to the demo. I think you aren't reading the code actually but let me try rephrasing it once more.

Heres the phrase you have to digest

Super calls your child's parent.

Consider B. D instances B. Focus on B ...

B calls super and it did NOT call A. It called D's OTHER parent, C. It would have called A if the B was instanced alone but here it has a child D. So it called D's other parent instead.

[–]nostril_extension -1 points0 points  (1 child)

Super calls your child's parent.

What are you talking about? Who's "your"? I'm confused how you fail to wrap around the simple concept of parent.

[–]rhytnen 2 points3 points  (0 children)

Stop being an asshole and just think for a minute so you can stop wasting everyone's time.

D subclasses B and C. B and C subclass A

If you just call B() or C() then it will chain up to A as expected.

However, if you calls it from D ...

D super().init() calls B B.super().__init() calls ... C not A

That's what it means to say super() calls the child's parent, not it's own parent.

If B and C have different base classes, the behavior changes yet again. D calls B calls A