Suppose I have a parent class A and a daughter class B. Now A has 10 methods in it and B requires only three of those methods. How can this be done?
jonrsharpe
123k31 gold badges278 silver badges489 bronze badges
asked Jun 18, 2015 at 19:15
Manish Kumar Singh
1831 gold badge1 silver badge8 bronze badges
1 Answer 1
There is nothing special to do.
Just inherit class A:
class B(A):
super(B, self).__init__():
Use/override the methods you need and ignore the rest.
answered Jun 18, 2015 at 19:50
Karpov
4231 gold badge6 silver badges13 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py
Bjust ignore the other seven methods? Or could you refactor the shared methods into a superclass that bothAandBshare, making them siblings? If you want to override inherited methods in a class, just implement them within that class definition.