Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

MoatazBellah Ghobashy
9,518 Pointsmultiplie superclasses....super() in sneaky and Agile
why call super() in Sneaky and Agile!!!, although these classes are not children for any class... Please help
3 Answers

Steven Parker
221,293 PointsWhat "super()
" does depends on the MRO, and in cases of multiple inheritance it may call a sibling class instead of a parent. That's what you see in these examples.
For more details, see the Python documentation for super().

Kafe Hezam
11,070 PointsHi Steven,
I really still didn't understand why call super() in Sneaky and Agile :( MRO means: Method resolution order:
- Childclass
- Parentclass
- builtins.object So, if python doesn't find it in the childclass then it goes to the parent class. If Python does not find it in the Child/Parent class then python should find it in the builtins.object class.
I read the python doc but still didn't understand:( Could you please provide examples so that I can understand it?:)

Steven Parker
221,293 PointsI added a comment with more details onto my answer.

Youssef Moustahib
7,779 PointsI tried the print method, it only printed from character, not agile or sneaky

Kafe Hezam
11,070 PointsUnderstood, thanks!!!!:)
Steven Parker
221,293 PointsSteven Parker
221,293 PointsA little experimentation might be more revealing than documentation or explanation. You might try printing a message at the end of the
__init__
method of each class. But here's what you'll see if you do that and instantiate an object of the class that has the multiple inherittance of(Sneaky, Agile, Character)
. "Sneaky" calls super, and the MRO directs it to Agile, which also calls super, which directs it to Character. So the printed messages will show that the inits for Character, then Agile, then Sneaky all ran, and completed in that order.MoatazBellah Ghobashy
9,518 PointsMoatazBellah Ghobashy
9,518 PointsThanks a lot :)