isinstance() and issubclass()

The isinstance() method checks whether an object is an instance of a class whereas issubclass() method asks whether one class is a subclass of another class (or other classes).

isinstance(object, classinfo)

Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof.

issubclass(class, classinfo)

Return true if class is a subclass (direct, indirect or virtual) of classinfo. A class is considered a subclass of itself. example
class MyClass(object): pass class MySubClass(MyClass): pass print(isinstance(MySubClass, object)) print(issubclass(MySubClass, MyClass)) print(isinstance(MySubClass, MyClass))
True True False