Back
This seems to occur a lot, and was wondering if this was a requirement in the Python language, or merely a matter of convention?
Also, could someone name and explain which functions tend to have underscores, and why (__init__, for instance)?
Below are the details of some of the important naming styles in Python:-
The use of _single_leading_underscore is for weak "internal use" indicator.
The single_trailing_underscore_ is used to avoid conflicts with Python keyword,
The __double_leading_underscore is used when naming a class attribute, invokes name mangling (inside class AbcPdf, __Abc becomes _AbcPdf__Abc).
While the __double_leading_and_trailing_underscore__ is called as "magic" objects or attributes that live in user-controlled namespaces.
31k questions
32.8k answers
501 comments
693 users