Name
isinstance
Synopsis
isinstance(obj
,cls
)
Returns True
when obj
is an instance of class cls
(or any
subclass of cls
) or when
cls
is a type object and
obj
is an object of that type. Otherwise
it returns False
.
Since Python 2.2.1, cls
can also be a
tuple whose items are classes or types. In this case,
isinstance
returns True
if
obj
is an instance of any of the items of
tuple cls
, otherwise
isinstance
returns False
.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.