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.

Horatiu Banciu
12,835 Pointssuper in a class with no parrent class
Ok soo in the Sneaky class in the init method there's this super call
class Sneaky:
sneaky = True
def __init__(self, sneaky=True, *args, **kwargs):
super().__init__(*args, **kwargs)
self.sneaky = sneaky
def hide(self, light_level):
return self.sneaky and light_level < 10
but there's no parent class so why does he use it? is he trying to call the __init__
method of the object class? is there any reason at all to do that?
1 Answer

Chris Freeman
Treehouse Moderator 68,154 PointsGood question! Kenneth designed the class Sneaky
so that it can be used as a “mix-in” class. As a mix-in class, it is intended to be used before other inherited classes and not as the sole inherited class. Without the super()
, any __init__
in a class following
sneaky
would not be run.
Post back if you need more help. Good luck!!!
Horatiu Banciu
12,835 PointsHoratiu Banciu
12,835 Pointssoo the mix-in classes could be seen as extensions to the base class?
Chris Freeman
Treehouse Moderator 68,154 PointsChris Freeman
Treehouse Moderator 68,154 PointsCorrect.
Horatiu Banciu
12,835 PointsHoratiu Banciu
12,835 Pointsthank you!