Issubclass () function in Python
The issubclass () function is built into Python to check if an object is a subclass of classinfo.
The built-in issubclass () function checks whether an object (first parameter) is a subclass of classinfo (the second parameter).
The issubclass () function syntax in Python
issubclass(object, classinfo)
Parameters of issubclass function ()
Issubclass () has 2 parameters:
object
: object to checkclassinfo
: class, type, or tuple
Value returned from issubclass ()
Function issubclass () returns:
True
if the object is a subclass subclass of the class or any element of the tuple.False
if vice versa.
Example: How is issubclass () function?
class DaGiac: def __init__(loaiDagiac): print('Da giac la ', loaiDagiac) class TamGiac(DaGiac): def __init__(self): DaGiac.__init__('tamgiac') print(issubclass(TamGiac, DaGiac)) print(issubclass(TamGiac, list)) print(issubclass(TamGiac, (list, DaGiac))) print(issubclass(DaGiac, (list, DaGiac)))
Run the program, the result is:
True False True True
Note that the class is also considered a subclass of itself.
See also: Built-in Python functions
Update 29 July 2019
You should read it
- Max () function in Python
- The ord () function in Python
- The map () function in Python
- The function id () in Python
- Sum () function in Python
- The oct () function in Python
- The function set () in Python
- Int () function in Python
- The next () function in Python
- Zip () function in Python
- Complex () function in Python
- The function dir () in Python
Maybe you are interested
What does the 'super slow' 7680fps movie recording feature on the Mate 30 Pro do? Hitman Sniper famous game is being free on iOS and Android How to create slow motion videos on Android? 8 ways to win people's hearts 6 tips to help you get out of debt Changing these 10 ways of speaking will help you advance like 'windy kites'.