yingfhu 5 months ago • updated by Alexander Shvets 5 months ago • 0
the code here seems wrong, the intention is to copy the object but use `dict.update` in the end which replacing the cloned object.
No wonder the new and self share the same ids. Therefore the last line of `__copy__` and `__deepcopy__` should be removed. Instead, in client code, the outside list and nested list and set should be altered and check individually, such as
# outside list not changed since copied shallow_copied_component.some_list_of_objects.append("another object") # inside nested list and set changed as well since shallow copied shallow_copied_component.some_list_of_objects[-1].append("another object") shallow_copied_component.some_list_of_objects.add(4)
Customer support service by UserEcho