True if class is subclass of given classinfo, False otherwise.
issubclass(class ,classinfo)
We created a parent ( base ) class animals(), then we derived sub class or child class wild(). Then we created birds() as child class of wild() class animals():
home='Jungle' #class attribute
#instance attributes
def __init__(self,name,height):
self.name= name
self.height=height
class wild(animals):
weight=2
class birds(wild):
name='Eagle'
print(issubclass(wild,animals)) # True
print(issubclass(birds,wild)) # True
print(issubclass(birds,animals)) # True
print(issubclass(animals,wild)) # False
print(issubclass(wild,wild)) # True
print(issubclass(wild,(str,list,animals))) # True
print(issubclass(wild,(str,list,animals))) # True
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.