locationCopy(loc)
Return a copy of an object, and anything in it
If object in the location refer to objects outside of the location, then the copies of the objects in the location refer to the same outside objects.
For example, suppose we have an object (location) hierarchy like this:
o1 / \ o2 o3 | | o4 o5
>>> o1 = Location() >>> o1.o2 = Location(); o1.o2.__parent__ = o1 >>> o1.o3 = Location(); o1.o3.__parent__ = o1 >>> o1.o2.o4 = Location(); o1.o2.o4.__parent__ = o1.o2 >>> o1.o3.o5 = Location(); o1.o3.o5.__parent__ = o1.o3
In addition, o3 has a non-location reference to o4.
>>> o1.o3.o4 = o1.o2.o4
When we copy o3, we should get a copy of o3 and o5, with references to o1 and o4.
>>> c3 = locationCopy(o1.o3) >>> c3 is o1.o3 0 >>> c3.__parent__ is o1 1 >>> c3.o5 is o1.o3.o5 0 >>> c3.o5.__parent__ is c3 1 >>> c3.o4 is o1.o2.o4 1