首页 > 编程语言 > 详细

[Python]Shallow and Deep copy operation

时间:2014-03-02 09:09:59      阅读:661      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!