In Python, issubclass(cls, base) returns True if the class cls inherits from base, directly or through other classes. A class counts as a subclass of itself, so issubclass(int, int) is True.
Like isinstance(), it accepts a tuple of base classes and returns True if any of them match. The difference is that issubclass() works on classes, while isinstance() works on instances.
issubclass() is a built-in function: it lives in the builtins module, so it is always available without an import.
Syntax
Both arguments are classes (the second may be a tuple).
python
ok = issubclass(ChildClass, BaseClass)
ok = issubclass(ChildClass, (BaseA, BaseB))
Call
What it does
issubclass(bool, int)
Returns True.
issubclass(int, bool)
Returns False.
issubclass(KeyError, LookupError)
Returns True.
issubclass(int, int)
Returns True: a class is its own subclass.
To see the full chain of parents in order, look at SomeClass.__mro__.
Library declarations
python
issubclass(class, classinfo, /)
Parameters
Parameter
Description
class
Required. The class to test (not an instance).
classinfo
Required. A class, a tuple of classes, or on 3.10+ a union like int | str.
Return Value
Return Value
Description
bool
True if class derives from classinfo.
Python Examples
Example 1 — Subclass Checks with Built-in Types
Test relationships between bool, int, object, and exception classes.
One direction only. bool inherits from int, but int does not inherit from bool.
Everything reaches object. Every class is a subclass of object.
Reflexive. A class is considered a subclass of itself.
Tuple of bases. ValueError is not a KeyError, but it is an Exception, so the result is True.
Example 2 — Find the Family of Each Exception
Check which broad exception family several specific errors belong to.
python
for err in [KeyError, ZeroDivisionError, FileNotFoundError]:
parents = [
base.__name__
for base in (LookupError, ArithmeticError, OSError)
if issubclass(err, base)
]
print(err.__name__, "->", parents)
print(issubclass(IndexError, LookupError))
Classes as values. Exception classes can be stored in a list and looped over.
Family membership. Each specific error belongs to exactly one of the three families tested.
Why it matters.except LookupError: catches both KeyError and IndexError.
Readable report.__name__ prints class names without the <class ...> wrapper.
Example 3 — A Three-Level Class Hierarchy
Check indirect inheritance, inspect the MRO, and pass an instance by mistake.
python
class Vehicle:
pass
class Car(Vehicle):
pass
class ElectricCar(Car):
pass
print(issubclass(ElectricCar, Vehicle))
print(issubclass(Vehicle, Car))
print([cls.__name__ for cls in ElectricCar.__mro__])
try:
issubclass(Car(), Vehicle)
except TypeError:
print("issubclass() needs a class, not an instance")
Output
True
False
['ElectricCar', 'Car', 'Vehicle', 'object']
issubclass() needs a class, not an instance
How It Works
Indirect inheritance. ElectricCar reaches Vehicle through Car.
Parents are not children. Vehicle is not a subclass of Car.
The MRO.__mro__ lists every class that is checked, from the class itself up to object.
Instance by mistake.Car() is an object, not a class, so Python raises TypeError.
Frequently Asked Questions
issubclass() compares two classes; isinstance() checks whether an object is an instance of a class.
Yes. issubclass(C, C) is always True.
Yes, pass a tuple: issubclass(cls, (A, B)) is True if cls derives from either.
The first argument must be a class. Use isinstance(obj, base) or issubclass(type(obj), base) for objects.
Look at cls.__mro__, which lists the class and all its ancestors in method resolution order.