Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial3 Answers
amyyxt
2,227 PointsDefinitions: Sometimes parent classes (aka superclasses) are base classes. By extension, sometimes child classes (aka subclasses) are derived classes or extensions (no pun intended).
Analogy & Diagrams + Other Resource: Just like how a person's family tree can be more of a web or starburst, the inheritance network of a multiple-inheritance scheme of Python classes can be represented with branches on either side of a class (but directionality is always that child classes can access parent attributes and methods, but parent classes canNOT access child attributes and methods).
Some diagrams and explanation can be found here: https://www.programiz.com/python-programming/multiple-inheritance
RPG Example from Video: The inheritance network in the video is something like this: (class object) / | \ (class Sneaky) (class Agile) (class Character) \ | / (class Thief)
Remember that the class object is the ultimate ancestor. Thief is an extension of base classes Sneaky, Agile, and Character. Thus, it has access to methods and attributes from Sneaky, Agile, and Character. In more intuitive or colloquial wording in the context of RPGs, a Thief is a Character who potentially possesses the qualities Sneaky and Agile.
Something that Kenneth mentioned but didn't really get into in this video is that we can create RPG classes/jobs that are extensions of Thief (which is probably why the file is named thieves, plural). Specifically, he mentioned "assassin" and "ninja." For these RPG jobs, we can make classes Assassin and Ninja as extensions of Thief since we'll probably want instances of them to initialize similar to how Thief instances initialize and possibly have the pickpocket skill (I imagine that being dextrous means that assassins and ninjas can easily learn to pickpocket even if we don't usually associate thieving with assassins and ninjas!).
Andrew Bickham
1,461 Pointsfacts! thank you I really appreciate it
matthewchvatal
4,661 PointsDidn't the "Kenneth" thief example initialize just fine when character came first in the tuple, though? What was gained from changing it?
Andrew Bickham
1,461 PointsAndrew Bickham
1,461 Pointsyou probably should have gotten this way sooner but thank you for your explanation, but if I may I have a question about the part towards the ending where Kenneth said " it would be better for the character class to the concrete or the last class the "thief" class inherits from? why?
once again thank you from the future
amyyxt
2,227 Pointsamyyxt
2,227 PointsRE: concrete class/last class to inherit from
Although in technicality, the very last class inherited from will always be the "object" class, we want a central node that anchors our inheritance network before it goes to the generic, built-in stuff. The "character" class is a natural candidate for our "thief" class since a thief is a type of character, and if we were real RPG developers, we'd have other characters, such as warriors, mages, archers, and more, which we'd create classes for and have them inherit from "character".
It's partly an organizational thing and partly because we may very well want all these characters to share some initialization properties, in which case having the "character" class comes in handy.