issubclass()
Built-in FunctionPython 2.0+Intermediate
Returns True if a class is a subclass of another class
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
print(issubclass(bool, int)) print(issubclass(int, object)) print(issubclass(str, (int, str)))
issubclass() is a built-in function that returns true if a class is a subclass of another class.
Try in PlaygroundTags
builtinfunctioncoreooptype-checkinginheritance
Related Items
isinstance()
Built-in Function
Returns True if an object is an instance of a given class or tuple of classes
type()
Built-in Function
Returns the type of an object, or creates a new type dynamically
abc
Stdlib — Typing
Abstract Base Classes: define interfaces subclasses must implement
__bases__
Dunder Attribute
Tuple of base classes of a class
__mro__
Dunder Attribute
Method Resolution Order; the order in which base classes are searched