Reloading a module means re-executing its content, in this case class A(object): pass
. So it creates another different class. It's the same behavior as:
class A(object):
pass
a = A()
class A(object): # a different class
pass
print isinstance(a, A) # False
This should be enough to explain why a bare reload()
is usually a bad idea. I'm sure others could point to frameworks that implement more sophisticated reloading procedures, e.g. patching the old class to be considered equal to the new one.