ReferenceBuilt-in functions
isinstance()
Checks whether an object is of a type, or of any type in a tuple.
Signature
isinstance(object, classinfo)Parameters
| Name | Means |
|---|---|
object | the value to test |
classinfo | a type, or a tuple of types |
Returns
A bool. Unlike comparing type(), it accepts subclasses.
Example
Python
print(isinstance(5, int))
print(isinstance(5, (str, float)))
print(isinstance(True, int))Output
True False True