1. Inspection and judgment
Issubclass (class, ClassInfo) if the first parameter is a subclass of the second argument, return True, Note:
- Non-strict (oneself can be considered to be their own subclass);
- The second parameter can be a tuple of more than one class, with any appropriate, true;
- Other cases to throw TypeError
Isinstance (object, ClassInfo) checks whether an instance object of the first argument belongs to a class
- The second parameter can be a tuple of more than one class, with any appropriate, true;
- Always returns False if the first parameter passed in is not an object type
- If the second argument is not a class or a tuple consisting of a class object, it throws a TypeError
2, point operation symbol access to object properties, attribute Related:
The Hasattr (object, Name) object has a set property name,name need to be enclosed in quotation marks, otherwise he will think of it as a variable,
GetAttr (object, name [, default]) Gets the name property of the object, if it does not exist, returns the default, if no default is set, it will be thrown if it does not exist attributeerror
- GetAttr (A, ' B ', ' The property you are accessing does not exist ')
SetAttr (object, name, value) sets the value of the object Name property to a new property if the property does not exist
Delattr (object, name) removes the established property if it is not thrown attributeerror
Property () Setting properties by property
- X = Property (GetSize, SetSize, delsize) set an X attribute that can manipulate GetSize, setSize, Delsize (write in advance) method
- X can be used as a calling interface, the method can be changed, such as changing the name, etc., to increase the method.
- How it works: combining several magical methods
Python: Class 2--bif built-in functions for classes and objects