Python: multiple calls to __init__() on the same instance

后端 未结 3 1550
一个人的身影
一个人的身影 2021-02-19 01:07

The __init__() function gets called when object is created. Is it ok to call an object __init__() function again, after its been created?



        
3条回答
  •  广开言路
    2021-02-19 01:57

    As far as I know, it does not cause any problems (edit: as suggested by the kosher usage of super(...).__init__(...)), but I think having a reset() method and calling it both in __init__() and when you need to reset would be cleaner.

提交回复
热议问题