In Python, how do you change an instantiated object after a reload?

前端 未结 7 1687
南方客
南方客 2021-02-04 06:25

Let\'s say you have an object that was instantiated from a class inside a module. Now, you reload that module. The next thing you\'d like to do is make that reload affect that c

7条回答
  •  甜味超标
    2021-02-04 07:26

    There are tricks to make what you want possible.

    Someone already mentioned that you can have a class that keeps a list of its instances, and then changing the class of each instance to the new one upon reload.

    However, that is not efficient. A better method is to change the old class so that it is the same as the new class.

提交回复
热议问题