Python isinstance() function
Definition and usage
If the specified object has the specified type, the isinstance() function returns True, otherwise returns False.
If the type parameter is a tuple, then if the object is one of the types in the tuple, this function will return True.
Syntax
isinstance(object, type)
Parameter value
Parameter | Description |
---|---|
object | Mandatory. Object. |
type | Type or class, or tuple of type and/or class. |
More instances
Instance
Check ke "Hello" ne kan type parameter tsofinsa
x = isinstance("Hello", (float, int, str, list, dict, tuple))
Instance
Check ke y ne instance of myObj:
class myObj: name = "Bill" y = myObj() x = isinstance(y, myObj)
Pages related
Reference Manual:issubclass() FanninKai sake object ne da aka na object na farko