I am playing with inheritance with python but got stuck when I try to modify the properties of a tuple. This is what I did:
class MyTuple(tuple):
def __init__(self):
super().__init__()
def add(self,number):
self = tuple(list(self)+[number])
Now when I use
x = MyTuple()
x.add(23)
x doesn't changed to (23)
, but is still ()
!
Am I doing something wrong or does this has to do something with hashing?