Python issubclass() Functie
Voorbeeld
Controleer of de klasse myObj
een subklasse is van
myAge
:
class myAge:
age = 36
class myObj(myAge):
name =
"John"
age = myAge
x = issubclass(myObj, myAge)
Definitie en gebruik
De issubclass()
functie retourneert
True
als het opgegeven object een subklasse is van het opgegeven object, anders False
.
Syntaxis
issubclass(object, subclass)
Parameterwaarden
Parameter | Description |
---|---|
object | Required. An object. |
subclass | A class object, or a tuple of class objects |
Gerelateerde pagina's
De functie isinstance() om te controleren of een object van een bepaald type is.