Skip to content
UPEEC

isinstance() and issubclass()

Check whether an object is an instance of a class (or tuple of classes), respecting inheritance.

Beginner
Comments 0
isinstance(3, (int, float))   # True
issubclass(bool, int)         # True — bool is a subclass of int

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.