What would be the best way to transfer references of objects from one list to another (move objects from one list to another). For clarity, I need to remove the objects from d[1]
after copying
class MyObject:
def __init__(self,v):
self.value = v
d = {1: [MyObject("obj1"),MyObject("obj2")], 2: []}
#which one?
#d[2] = [obj for obj in d[1]]
#d[2] = d[1][:]
#d[2] = d[1].copy()
#clear d[1]
#d[1] = []
for i in range(len(d[1])):
d[2].append(d[1].pop(0))
for o in d[2]:
print (o.value)