Python issubclass() FunctionPython Functions


The issubclass() method is used to determine whether an object (the first argument) is a subclass of classinfo (the second argument).

Example

#!/usr/bin/python
# -*- coding: UTF-8 -*-

class A1:
    pass

class B(A1):
    pass

print(issubclass(B, A1))  # return true

Output:

True

Syntax

issubclass(object, classinfo)

Parameters

Name Description
object Class to be checked
classinfo Class, type, or tuple of classes and types

Return Value

It returns true if the object is a subclass, or it will return false.

© 2021 Programtips.org, all rights reserved. Privacy Policy | Contact Us