Create new class instance from class method

后端 未结 6 2037
攒了一身酷
攒了一身酷 2020-12-23 19:39

I want to be able to create a new instance of an object by calling a method on an already instantiated object. For example, I have the object:

organism = Organ

6条回答
  •  礼貌的吻别
    2020-12-23 20:39

    why not simply use the copy module?

    import copy
    organism = Organism()
    replica = copy.deepcopy(organism)
    

提交回复
热议问题