PYTHON specifies special variables with underscores as variable prefixes and suffixes.
_xxx cannot be imported with ' from Moduleimport * '
__xxx__ System Definition Name
Private variable names in the __xxx class
Core style: Avoid using underscores as the start of variable names.
Because underscores have special meanings for the interpreter and are symbols used by built-in identifiers, we recommend that programmers avoid using underscores as the starting point for variable names. In general, variable name _xxx is considered "private" and cannot be used outside of a module or class. When a variable is private, it is good practice to use _xxx to represent variables. Because the variable name __xxx__ has a special meaning for Python, this naming style should be avoided for common variables.
A member variable that starts with a "single underline" is called a protection variable, meaning that only class objects and subclass objects can access these variables themselves;
A "double underline" begins with a private member, meaning that only the class object can access it, and the child object cannot access the data.
A class attribute that begins with a single underscore (_foo) cannot be accessed directly, and is accessed through the interface provided by the class, cannot be imported with a "from XXX import *", and a double underscore (__foo) represents a private member of the class; A double underscore that starts and ends (__foo__ Represents a special method-specific identifier for Python, such as __init__ (), which represents the constructor of a class.
Conclusion:
1. _xxx cannot be used for ' from module import * ', which begins with a single underscore, is a variable of type protected. That is, the protection type can only allow access to its own and subclasses.
2, __xxx double underline is a variable of the private type. Only allow access to the class itself. You can't even subclass it.
3. __xxx___ defines the method of the special column. Like __init__ or something.
The difference between a single underline and a double underline in Python (private and protected)