class NPArrayLike:
def __init__(self, list):
self._list = list
def __getitem__(self, indices):
return [self._list[idx] for idx in indices];
if __name__ == "__main__":
out = NPArrayLike([1,2,3,4,6])
indices = [0,1,4,3,1,2,1]
print(out[indices]) # [1, 2, 6, 4, 2, 3, 2]
Wouldn't it be like this if you emulate it?
© 2024 OneMinuteCode. All rights reserved.