Re: deep copy

Jack Jansen (Jack.Jansen@cwi.nl)
Fri, 26 Jun 1992 11:33:35 +0200

How about:
def deepcopy(p):
if type(p) == type([]):
p = p[:]
for i in range(len(p)):
p[i] = deepcopy(p[i])
return p

This will copy lists and keep references to all other objects.
Extending it to also copy other mutable objects like dictionaries is
left as an excercise to the reader:-)

And, of course, Guido will probably post a much more elegant and
efficient solution:-)

--
Jack Jansen        | If I can't dance I don't want to be part of
Jack.Jansen@cwi.nl | your revolution             -- Emma Goldman
uunet!cwi.nl!jack    G=Jack;S=Jansen;O=cwi;PRMD=surf;ADMD=400net;C=nl