I can't figure out how to solve an issue I have when using reload in my program. If my code is like
import mymodule
from mymodule import MYCLASS
x = MYCLASS()
then everything works fine. However if I try to reload the module like this:
import mymodule
from mymodule import MYCLASS
x = MYCLASS()
reload(mymodule)
y = MYCLASS()
I get some weird error. I understand that maybe is because the reference of MYCLASS and of mymodule have changed, but can't understand exactly why and how to prevent it.
What is the correct way to reload modules and classes imported in such a case?