Copy constructor in python?

后端 未结 7 925
逝去的感伤
逝去的感伤 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:45

    For your situation, I would suggest writing a class method (or it could be a static method or a separate function) that takes as an argument an instance of the library's class and returns an instance of your class with all applicable attributes copied over.

提交回复
热议问题