First, static methods (Staticmethod) and class methods (Classmethod)
Class method: There is a default parameter CLS, and can be called directly with the class name, you can interact with class properties (that is, you can use class properties)
static method: Let the method in the class be called directly by the class, just like the normal calling function
The same point of a class method and a static method: All can be called directly by the class, without the need to instantiate
The difference between a class method and a static method:
The class method must have a CLS parameter representing the class, and you can use the Class property
Static methods do not require parameters
Binding methods: Divided into common methods and class methods
Common method: A Self object is passed in by default and can only be called by an object-------bound to an object
Class method: A CLS object is passed in by default and can be called by classes and objects (not recommended)-----bound to a class
Unbound methods: Static methods: No default parameters are set and can be called by classes and objects (not recommended)-----unbound
Class Foo: passclass Son (Foo): passs = Son () print (Isinstance (S,son)) #判断s是不是Son的对象print (type (s) is Son) Print (Isinstance (s,foo)) #判断s是不是Foo的对象 not accurate print (type (s) is Foo) #type比较精准print (Issubclass (Son,foo)) # Determine son is not a subclass of Foo print (Issubclass (son,object)) print (Issubclass (foo,object)) print (Issubclass (int,object))
Python Series Reflection