This page is based on
The Meaning of Underscores in Python
Dan Bader's blog post.
_foo | convention-only, PEP8 | hint about internality of method |
foo_ | convention-only, PEP8 | avoiding a keyword/naming conflict |
__foo | name mangling (prefixing) | name gets rewritten by prefixing with _{class name} . Idk what happens when they are import–renamed. |
__foo__ | called/used by language | name might have special meaning and special use in the language, usually just in case of methods, now or in the future. Might override pre-set stuff of the language. afaik field names can also conflict with method names just as well, contrary what one professor once seemed to tell me. |