check isinstance python code example

Example 1: isinstance python

isinstance(object, classinfo)

# if classinfo is a tuple of type objects (or recursively, other such tuples), return True
# if object is an instance of any of the types. If classinfo is not a type or tuple of types
# and such tuples, a TypeError exception is raised.

Example 2: python isinstance

x = isinstance(5, int)

Example 3: isinstance several variables

'check if variables days, months or years are all integers
if not all(isinstance(i, int) for i in [days, months, years]):

Tags:

Misc Example