Class is a collection of data (variables and methods). It bundles data and functionality together. It provides all standard features of object-oriented programming. Basically it is a blueprint for creating objects. Creating a new class creates a new type of object, allowing new instances of that type to be made.
The value of a: 7
__subclasscheck__ in Python
__subclasscheck__ is one of the methods to customize the result of
issubclass() built-in function. It is a method to check whether a class is a subclass or not and returns
True if the class is considered as a subclass(direct or indirect) of another class, otherwise, returns
False. It cannot be defined as a class method in the actual/real class. It is implemented in the metaclass, as it is not for ordinary classes. Consider the below example for better understanding.
Example: Consider a situation where you want to check if a certain value is present as an attribute inside a class using the
True False True
__subclasshook__ in Python
Abstract class can override
__subclasshook__() method to customize
issubclass(). It returns
True when a class is found to be subclass of a ABC class, it returns
False if it is not and returns NotImplemented if the subclass check is continued with the usual mechanism. This method is defined in the ABC class with some conditions. Classes that follow those conditions are considered to be a subclass.
Note: It must be defined as a class method.
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.
- Important differences between Python 2.x and Python 3.x with examples
- Creating and updating PowerPoint Presentations in Python using python - pptx
- Loops and Control Statements (continue, break and pass) in Python
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
- Python | Using variable outside and inside the class and method
- Releasing GIL and mixing threads from C and Python
- Python | Boolean List AND and OR operations
- Difference between 'and' and '&' in Python
- Replace the column contains the values 'yes' and 'no' with True and False In Python-Pandas
- Ceil and floor of the dataframe in Pandas Python – Round up and Truncate
- Login Application and Validating info using Kivy GUI and Pandas in Python
- Get the city, state, and country names from latitude and longitude using Python
- 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
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.