search

What is the use of the "issubclass" function in Python?

The **issubclass** function in Python is used to check if a class is a subclass of another class. It takes two arguments, the first is the subclass and the second is the class or tuple of classes to check if the first is a subclass of. It returns a Boolean value indicating whether the subclass is a subclass of the specified class or not.

Syntax:

issubclass(class, classinfo)

Example:

class A:
  pass

class B(A):
  pass

class C:
  pass

print(issubclass(B, A))  # True
print(issubclass(C, A))  # False

Related Questions You Might Be Interested