I created 2 class instances(stack0, stack1) from a class Stack There is a class variable named in class Stack, which has the other stack address(reference), ie) stack0.other_stack is stack1 and stack1.other_stack is stack0. but It doesn't work as I expected though I used deepcopy function.
I tried making a class function that deepcopies the other_stack.
stack0 = Stack(stack_list, arr_size//2, 0)
stack1 = Stack(stack_list, arr_size//2, 1)
stack0.other_stack = deepcopy(stack1)
stack1.other_stack = deepcopy(stack0)
print(stack0.other_stack is stack1)
print(id(stack0.other_stack), id(stack1))
print(stack0.other_stack is stack1) prints: False
print(id(stack0.other_stack), id(stack1)) prints: 4328836344 4328835224
I expected stack0.other_stack is the exactly same as stack1 and vice-versa.