Checking for types & is
Check for Types
Check if variable is an instance of a type (e.g. str, int, bool)
if isinstance(var, type):
Check if the value is JUST that type
if type(var) is type:
is
is checks for their “true nature” (types), and can only be used to compare between those two things.
1 is int # False
a = None
a is None # True
b = True
b is True # True
b is False # False
#python #snippet #python/features