English documents:
isinstance
(object, classinfo)
Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect o R Virtual) subclass thereof. If Object is a object of the given type, the function always returns FALSE. If ClassInfo is a tuple of type objects (or recursively, and other such tuples), return True if the object is an Instance of any of the types. If ClassInfo is a type or a tuple of types and such tuples, a TypeError
exception is raised.
Description
1. The function function is used to determine whether an object is an instance of a type object, which represents the object to be inspected, and the Calssinfo parameter represents the type object.
2. Returns true if the object parameter is an instance of the ClassInfo type (or the direct, indirect, virtual subclass of the ClassInfo class object).
>>> isinstance (1, int) True>>> isinstance (1, str) False#Definitions 3 Categories: C Inherits B,b inheritance a>>>classA:Pass>>>classB (A):Pass>>>classC (B):Pass>>> A =A ()>>> B =B ()>>> C =C ()>>> isinstance (A,a)#Direct InstanceTrue>>>Isinstance (A, b) False>>> isinstance (B,a)#sub-class instancesTrue>>> isinstance (C,a)#Grandson Class ExampleTrue
3. Always return FALSE if the object parameter is passed in to a type.
>>> isinstance (str,str) false>>> isinstance (bool,int) False
4. If the ClassInfo type object is a tuple of multiple type objects, returns True if the Object object is an instance of any type object in the tuple, otherwise false is returned.
>>> Isinstance (A, (b,c)) False>>> isinstance (A, (a,b,c)) True
5. If the ClassInfo type object is not a type object or a tuple of multiple type objects, an error (TYPEERROR) will be made.
>>> isinstance (A,[a,b,c]) Traceback (most recent): "<pyshell#23> " in<module> or tuple of types
Python built-in function (--isinstance)