Horatiu Banciu11,360 Points
super 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?
Chris FreemanTreehouse Moderator 56,649 Points
Good 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
__init__ in a class following
sneaky would not be run.
Post back if you need more help. Good luck!!!