yoma wrote:
python version 2.5 in module copy
we all know that copy have two method: copy() and deepcopy().
and the explain is
- A shallow copy constructs a new compound object and then (to the
extent possible) inserts *the same objects* into it that the
original contains.
- A deep copy constructs a new compound object and then, recursively,
inserts *copies* into it of the objects found in the original.
Read a little further: This module does not copy types like module,
method, stack trace, stack frame, file, socket, window, array, or any
similar types. It does ``copy'' functions and classes (shallow and
deeply), by returning the original object unchanged
so i try a example:
import copy
class A:
i = 1
class B:
a = A()
b = B()
The only attribute of b itself is .__class__ == B, which as the above
says, is 'copied' by not being copied. So either shallow or deep copies
of b will have .__class__ == the original B with its original instance
of a.
tjr
--
http://mail.python.org/mailman/listinfo/python-list