Built-in Functions and Types
issubclass()
Check whether a class inherits from, is identical to, or is recognized as a virtual subclass of another class. Use a tuple or valid union type to check several alternatives. This tests a class relationship rather than an individual value; passing a non-class first argument or invalid class information can raise TypeError.
Formal Syntax & Structure
python syntaxpython
issubclass(class, classinfo, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| class | type | Class to inspect. |
| classinfo | type | tuple of types | union type | Candidate base classes, including nested tuples. |
Return Value
bool
True if the tested class matches an applicable subclass relationship.
Working Example
Example Snippetpython
class Vehicle: pass
class Bicycle(Vehicle): pass
print(issubclass(Bicycle, Vehicle))print(issubclass(Vehicle, Vehicle))print(issubclass(Vehicle, Bicycle))