How does the Python isinstance
function work internally? Is there anything I can do to alter its results, like define a special function inside a class or something? Here's my use case:
class Decorator:
def __init__(self, decorated):
self._decorated = decorated
def __call__(self):
return self._decorated()
@Decorator
class Foo:
pass
f = Foo()
# How can I make this be true?
isinstance(f, Foo)
Decorator
acts almost like a mixin, except a mixing wouldn't be appropriate here. Is there any way I can make the above code work? I should also note that the isinstance
line also gives the following error:
isinstance(f, Foo)
TypeError: isinstance() arg 2 must be a type or tuple of types