Generalized encapsulation: Instantiates an object and encapsulates some properties for the object space. Narrowly encapsulated: Private Private members: Privately owned static fields, private methods, private object properties for private static fields, private methods, private object properties, outside of the class cannot be accessed.----#instantiated objects cannot access private static fields, private methods, private object Properties----#class name cannot access private static fields, private methods, private object Propertiesfor private static fields, private methods, private object properties, the inside of the class can be accessed. For private static fields, private methods, private object properties, can only be accessed internally within this class, outside of the class, Derived classes are inaccessible. Hides the property (set to private) in Python, starting with a double underscore----#Actually, this is just a warp operation .----#names that begin with all underscores in a class, such as __x, automatically become: _ Class name __x form----features of this automatic deformation:--------1. The __x defined in the class can only be used internally, such as self.__x, the reference is the deformation to get the result. --------2This variant is actually for external deformation, which cannot be accessed externally by the name __x.--------3__x does not overwrite the __x defined by the parent class when the subclass is defined, because the subclass is formed: The subclass name __x, and the parent class becomes: _ The parent class name __x The property that begins with the double underscore is not overridden by the subclass when it inherits to the subclass. This type of deformation requires attention to the following issues:------------1This mechanism also does not really limit our direct access to properties from the outside, knowing the class name and property name can spell the name: _ Class Name __ Property name------------2The process of morphing occurs only once in the definition of a class, after the defined copy operation, does not deform. ------------3in inheritance, fathers can define methods as private if they do not allow subclasses to overwrite their own methods. Encapsulation is not a mere sense of concealment1. Encapsulating Data----hiding data is not an end in itself. Hide it and then provide an interface to manipulate the data externally, and then we can complete the rigor of data property operations by restricting the operation of the data on the interface attachment. 2. Encapsulation Method----witnessing is the isolation of complexity. Hint: In a programming language, an externally provided interface (an interface can be understood as a portal) can be a function, called an interface function, which is not the same as the concept of an interface, which represents a set of interface functions.
Python Object-oriented encapsulation