The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances).
import copy class MyKlass(object): def __init__(self,name): self.name = name def test(self): print "this is " + self.name class MyDict(dict): pass def myFunction(): print "this is function" if __name__ == ‘__main__‘: k = type(MyKlass) print k NewClass = copy.copy(MyKlass) NewClass("Python").test() d = type(MyDict) print d.__base__ f = type(myFunction) print f.__name__
[Python]Shallow and Deep copy operation,布布扣,bubuko.com
[Python]Shallow and Deep copy operation
原文:http://blog.csdn.net/wonderfan/article/details/20206879