While using the reload in my program, I can not seem to solve a problem if my code Like Then everything works fine though if I reload the module like this Try to: I get some strange error Not think that maybe because In such cases, what is the correct way to reload the imported modules and classes? You should reload the following styles. If a module imports from other modules ... import ..., by reloading for other modules () it does not redefine the imported objects ??? It has to be executed in a way around the statement again, someone else is using the import and the appropriate name (module. name ) instead. UPDATE MYCLASS and
mymodule references have changed, but really do not understand it and how to prevent it.
Import mymodule x = mymodule.MYCLASS () mymodule = reload (mymodule) y = mymodule.MYCLASS ()
Recovery (x, mymodule.MYCLASS) will be
incorrect , As the class is restarted, but
x.__ class__ still references the old class.
& gt; & Gt; & Gt; Isinstance (x, mymodule.myCLASS) false & gt; & Gt; & Gt; Isinstance (y, mymodule.MYCLASS) is true
No comments:
Post a Comment