member by member copy???

Thomas Thiele thiele at muc.das-werk.de
Wed May 10 11:29:54 EDT 2000


> Use copy.copy and copy.deepcopy.

>>> class X:
...     def __init__(self):
...             self.a = 5
...
>>> x = X()
>>> list = [x]
>>> cl1 = copy.copy(list)
>>> cl2 = copy.deepcopy(list)
>>> list[0].a = 6
>>> list[0].a
6
>>> cl1[0].a
6
>>> cl2[0].a
5

Thomas




More information about the Python-list mailing list