Created
April 11, 2020 17:58
-
-
Save gwsu2008/014648ec89960f7d1471715858a51419 to your computer and use it in GitHub Desktop.
python_underscore.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Single Leading Underscore: _var | |
The underscore prefix is meant as a hint to another programmer that a variable or method starting with a single underscore is intended for internal use. This convention is defined in PEP 8. | |
2. Single Trailing Underscore: var_ | |
In summary, a single trailing underscore (postfix) is used by convention to avoid naming conflicts with Python keywords. This convention is explained in PEP 8. | |
3. Double Leading Underscore: __var | |
A double underscore prefix causes the Python interpreter to rewrite the attribute name in order to avoid naming conflicts in subclasses. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment