I am trying to write a stupid __instancecheck__
for class Class
so the following will print False
:
c = Class()
print(isinstance(c, Class)) # False
I tried to put __instancecheck__
in Class, BaseClass and MetaClass, but nothing works. Here is the code:
class MetaClass(type):
def __instancecheck__(self, instance):
return False
class BaseClass(metaclass=MetaClass):
def __instancecheck__(self, instance):
return False
class Class(BaseClass, metaclass=MetaClass):
def __instancecheck__(self, instance):
return False
c = Class()
print(isinstance(c, Class)) # True
The doc says the method should be in metaclass, I did it, and it's not working and I can't inderstand why. Please tell me where I am wrong.