We know that inheritance is one of the building blocks of Object-Oriented Programming concept. It is the capability of one class to derive or inherit the properties from some other class. It also provides the reusability of code. We don’t have to write the same code again and again. Also, it allows us to add more features to a class without modifying it.
Refer to the below articles to get the idea about OOPs and Inheritance in Python.
issubclass() is built-in function used to check if a class is a subclass of another class or not. This function returns
True if the given class is the subclass of given class else it returns
Syntax: issubclass(object, classinfo)
Object: class to be checked
classinfo: class, types or a tuple of classes and types
Return Type: True if object is subclass of a class, or any element of the tuple, otherwise False.
True False True True
Note: Don’t get confused between
issubclass() as both these method are quite similar. However, the name itself explain the differences.
isinstance() checks whether or not the object is an instance or subclass of the classinfo. Whereas,
issubclass() only check whether it is a subclass of classinfo or not (not check for object relation).
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- OOP in Python | Set 3 (Inheritance, examples of object, issubclass and super)
- Important differences between Python 2.x and Python 3.x with examples
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- MySQL-Connector-Python module in Python
- Python - Read blob object in python using wand library
- Python | PRAW - Python Reddit API Wrapper
- twitter-text-python (ttp) module - Python
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python program to check if the list contains three consecutive common numbers in Python
- Creating and updating PowerPoint Presentations in Python using python - pptx
- How to write an empty function in Python - pass statement?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.