Python Object-Oriented Python Inheritance Super-Duper!

Ross Nation
Ross Nation
4,674 Points

remove sneaky = True from Thief class?

I notice that Kenneth leaves sneaky = True in the Thief class above the init method. As the init method now contains that variable, would it be best practice to now remove that from being a class variable (may be using some incorrect terminology here...)? Or does it serve some purpose that I don't understand?

2 Answers

Steven Parker
Steven Parker
203,995 Points

It's possible for a class to have a class attribute and an instance attribute with the same name, and it's not clear if the class attribute might have some use later on.

But you're right, if you don't intend to use the class attribute for something else, it would be a good idea to remove it when you replace it with an instance attribute.

Abdulsalam Jumah
Abdulsalam Jumah
3,595 Points

I can't fully respond to your question from the video, but I can say that we have created a new class it should have some of its own initial attributes and methods or else whey even inherit the class or create a new one, but honestly I don't feel that problem or situation the teacher introduced is very convincing that's why I see many people confused. because I have tried to call thief class and use and set the sneaky attribute to False and it worked without me using super if I didn't set it to false it would still be there and be True .