What is the issubclass() method in Python?

The issubclass() method is used to determine if a class is a subclass of a specified class.

  • It returns True if a class is a subclass of the specified class
  • It returns False if a class is not a subclass of the specified class
Function signature

classinfo can be specified as a tuple of class objects. In that case, every entry in classinfo is checked. isubclass() returns True if class is a subclass of any element in the tuple.

Code

In the code below, we check if the Kiwi class is a subclass of the Fruit class. Since it is, issubclass() returns True.

class Fruit:
def __init__(fruittype):
print(fruittype)
class Kiwi(Fruit):
def __init__(self):
Fruit.__init__('Kiwi')
print(issubclass(Kiwi, Fruit))

In the following code snippet, we check if Kiwi is a subclass of Fruit and Vegetable. Since Kiwi is a subclass of Fruit, issubclass() returns True.

class Fruit:
def __init__(fruittype):
print(fruittype)
class Vegetable:
def __init__(vegetabletype):
print(fruittype)
class Kiwi(Fruit):
def __init__(self):
Fruit.__init__('Kiwi')
print(issubclass(Kiwi, (Fruit, Vegetable)))

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved