Copy constructor in python?

后端 未结 7 916
逝去的感伤
逝去的感伤 2020-11-29 02:29

Is there a copy constructor in python ? If not what would I do to achieve something similar ?

The situation is that I am using a library and I have extended one of t

7条回答
  •  暖寄归人
    2020-11-29 02:58

    I think you want the copy module

    import copy
    
    x = copy.copy(y)        # make a shallow copy of y
    x = copy.deepcopy(y)    # make a deep copy of y
    

    you can control copying in much the same way as you control pickle.

提交回复
热议问题