I have a custom setitem() function.
class Myclass:
array = [[[1]*3]]
def __setitem__(self, idcs: tuple, other):
# do something
array[idcs] = other
return 2
I would like to do something like this:
x = Myclass()
other = [1, 2, 3]
z = x.__setitem__([0:1, 0:1, 0:], other) # change the given range of x and assign the return value to
But it doesn’t work and returns Invalid Syntax error. I expect the result to be this:
z == 2
x.array == [[[1, 2, 3]]]
What should I do?