I have something like this:
def Class1:
...
def __getitem__(self, index):
...a lot of code
a = query["label_1"].iat[index]
...some more operations
return a
def Class2(Class1):
...
def __getitem__(self, index):
...a lot of code which is the same as Class1
a = query["label_2"].iat[index]
...some more operations which are identical in Class1
return a
As you can see, both "__getitem__
" functions are basically the same, but only changes "label_1" to "label_2". There is a way to not to overwrite the entire method in Class2 just because of a little change?