5
Wie kann ich überprüfen, ob ein Typ ein Untertyp eines Typs in Python ist? Ich beziehe mich nicht auf Instanzen eines Typs, sondern vergleiche Typinstanzen selbst. Zum Beispiel:Wie kann ich prüfen, ob ein Typ ein Untertyp eines Typs in Python ist?
class A(object):
...
class B(A):
...
class C(object)
...
# Check that instance is a subclass instance:
isinstance(A(), A) --> True
isinstance(B(), A) --> True
isinstance(C(), A) --> False
# What about comparing the types directly?
SOME_FUNCTION(A, A) --> True
SOME_FUNCTION(B, A) --> True
SOME_FUNCTION(C, A) --> False