I do something like this,
class MetaA(type):
def __instancecheck__(self, obj):
print('hello world')
return super().__instancecheck__(obj)
class A(metaclass=MetaA):
pass
a = A()
isinstance(a, A)
gives,
True
whereas,
isinstance(None, A)
gives,
hello world
False
why did it not print hello world
the first time?
when I create another class,
class C(A):
pass
and then,
a = C()
isinstance(a, A)
gives,
hello world
True
but,
isinstance(a, C)
gives,
True
why does it not print hello world
sometimes?