How can you check if an object is an instance of a class but not any of its subclasses (without knowing the names of the subclasses)? So if I had the below code:
def instance_but_not_subclass(object, class):
#code
return result
class item(object):
class item_2(item):
...
class item_n(item):
a = item()
b = item_2()
...
c = item_n()
instance_but_not_subclass(a, item)
instance_but_not_subclass(b, item)
...
instance_but_not_subclass(c, item)
what would go in the #code
space that would produce the output?:
True
False
...
False
Because issubclass()
and isinstance()
always return True
.