I would not think that a generic deepcopy would work for all cases. An object can be as simple as a number, for instance, but can also be as complex as the universe. I can't imagine anybody would know how to copy a complex object otherthen the object itself.
I always think that a well designed object should have a copyme method. :=) "Bob Van Zant" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ha. I just read down to the bottom of pyDoc page. > > "This version does not copy types like module, class, function, method, > nor stack trace, stack frame, nor file, socket, window, nor array, nor > any similar types." > > However, I actually tried it and it worked at least in the simple case: > >>> class x: > ... def __init__(self): > ... self.y = 1 > ... > >>> obj = x() > >>> obj.y > 1 > >>> > >>> import copy > >>> z = copy.deepcopy(obj) > >>> z.y > 1 > >>> obj.y = 4 > >>> obj.y > 4 > >>> z = copy.deepcopy(obj) > >>> z.y > 4 > > -Bob > > On Wed, 2004-12-29 at 10:42 -0800, Bob Van Zant wrote: > > copy.deepcopy() should do the trick. This URL answers a little bit of > > your question about the difficulties in copying "complex" data > > structures. > > > > http://pydoc.org/2.3/copy.html > > > > -Bob > > > > On Wed, 2004-12-29 at 19:29 +0100, harold fellermann wrote: > > > Hi all, > > > > > > In the documentation of module 'copy' it is said that "This version > > > does not copy types like module, class, function, method, stack trace, > > > stack frame, file, socket, window, array, or any similar types." > > > > > > Does anyone know another way to (deep)copy objects of type class? What > > > is special about the objects of these types that they cannot be easily > > > copied? > > > > > > Any help appreciated, > > > > > > - harold - > > > > > > > > > -- > > > I like pigs. Dogs look up to us. Cats look down to us. > > > Pigs treat us as equal. > > > -- Winston Churchill > > > > > > -- http://mail.python.org/mailman/listinfo/python-list