Given the following two .py files:
aclass.py
class A(object):
    pass
main.py
def importer(klass):
    """
    Used to import classes from there python qalname
    """
    import_ = lambda m, k: getattr(__import__(m, fromlist=k), k)
    klass = klass.split('.')
    module = '.'.join(klass[:-1])
    klass = klass[-1]
    return import_(module, klass)
from aclass import A
import_A = importer('aclass.A')
print isinstance(A(), import_A)  # Expected to be true 
print isinstance(import_A(), A)  # Expected to be true 
At this stage, everything works fine (my program prints True\nTrue)
But if I modify the importer method to enforce a reload, ie:
this line:
    import_ = lambda m, k: getattr(__import__(m, fromlist=k), k)
is replaced by:
    import_ = lambda m, k: getattr(reload(__import__(m, fromlist=k)), k)
my programs returns
False
False
And I do not understand this behavior.
 
    