Definition
The isinstance() function returns True
if the specified object is of the specified type, otherwise False
.
Syntax
isinstance(object, type)
Parameters
Parameter | Description |
---|---|
object | Required. An object. |
type | A type or a class, or a tuple of types and/or classes |
Examples
myInt = isinstance(19, int)
print(myInt)
myString = isinstance("Ivan", (float, int, str, list, dict, tuple))
print(myString)
class myCar:
name = "Ford"
car = myCar()
result = isinstance(car, myCar)
print(result)