Python issubclass() Function

Python 内置函数Python Built-in Functions


Description

issubclass()The method is used to determine whether the parameter class is a subclass of the type parameter classinfo.

Syntax

The following is the syntax for the issubclass() method:

issubclass(class, classinfo)

Parameters

  • class -- A class.
  • classinfo -- A class.

Return Value

Returns True if class is a subclass of classinfo, otherwise returns False.


Example

The following demonstrates an example of using the issubclass function:

#!/usr/bin/python # -*- coding: UTF-8 -*- class A: pass class B(A): pass print(issubclass(B,A)) # Returns True

Python 内置函数Python Built-in Functions

Other Extensions