I have run across a piece of code that at first glance seems pointless. But I realize that this could have some unknown implications that I am not aware of as Python is not my most known language.
import copy
node = copy.copy(node)
Reading the documentation of copy it says that
copy.copy(x) Return a shallow copy of x.
A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it to the objects found in the original.
Does this code do anything? The node that it is copying is being taken from a scene list of objects. Is it creating a copy of just the root level of the class so it can change variables (name) but not effect the original in the list? The node class contains several node children.
How does
copy.copy(node)differ fromnode = nodeIs one constructing a new object while the other is simple pointing to the same object?