Python - 自定义深度复制调用默认实现

时间:2016-11-07 17:21:23

标签: python python-3.x inheritance python-internals

我尝试编写一个首先调用默认实现的自定义deepcopy,然后执行额外的操作

就是这样:

class Foo(object):
    def __deepcopy__(self, memo):
        cp = super(Foo, self).__deepcopy__(memo)
        # custom treatments
        return cp

但是,当我致电deepcopy(Foo())时,我收到以下错误:

  

AttributeError:'super'对象没有属性' deepcopy '

我怎么能从这里调用默认的深度复制?

0 个答案:

没有答案
相关问题