Legitimacy of deepcopy

Eugeni Doljenko dolzenko at rsu.ru
Fri Jun 4 14:07:05 CEST 2004

There is a list of custom objects. I want do duplicate this list to modify
objects in new list and then compare old and new. I could do it with

class foo:
    def __init__(self, str):
        self.str = str
old = [foo('str1'), foo('str2')]

import copy
new = copy.deepcopy(old)

But I've found very few deepcopy uses in Python library and other programs,
so I wonder it's possible to do it other, more elegant way.

More information about the Python-list mailing list