How do you clone a class in Python?

前端 未结 4 1934
遥遥无期
遥遥无期 2021-01-03 01:03

I have a class A and i want a class B with exactly the same capabilities. I cannot or do not want to inherit from B, such as doing class B(A):pass Still i want B to be ident

4条回答
  •  伪装坚强ぢ
    2021-01-03 01:53

    You can clone the class via inheritance. Otherwise you are just passing around a reference to the class itself (rather than a reference to an instance of the class). Why would you want to duplicate the class anyway? It's obvious why you would want to create multiple instances of the class, but I can't fathom why you would want a duplicate class. Also, you could simply copy and paste with a new class name...

提交回复
热议问题