Wellcome to the world of modules and namespaces!
Here is what happens:
In module m2, you import A from module m1. So you create a class m2.A
as a reference to class m1.A
. It happens to have the same definition as __main__.A
, but they are different objects, because the main module is named __main__
and not m1
. Then in module __main__
you create a class __main__.B
as a reference to class m2.B
To better understand what happens here, I have added some code to m1:
...
print(issubclass(B, A))
import m1
import m2
print(A == m1.A, m1.A == m2.A)
print(B == m2.B)
print(issubclass(B, m2.A), issubclass(B, m1.A))
The output is:
False
False True
True
True True
Proving that B is indeed a subclass of m1.A
but not of __main__.A
.