My question is will the init method of list class calling other method such as append or insert to achieve its functionality.
like:
class test(list):
def __init__(self,values):
super().__init__()
def append(self, value):
self.append(value + 1)
I want:
x = test([1,2,3])
x
[2,3,4]
but I got:
[1,2,3]
I know I can make it work by overload init itself.
def __init__(self,values):
super().__init__([x+1 for x in values])
Can I just overload some basic value insert method like setitem, so all the insert operation like append, insert will call it, and therefore have that addition effect.
thanks for any suggestion.