__method
: private method.__method__
: special Python method. They are named like this to prevent name collisions. Check this page for a list of these special methods._method
: This is the recommended naming convention for protected methods in the Python style guide.
From the style guide:
_single_leading_underscore
: weak “internal use” indicator. E.g.from M
does not import objects whose name starts with an underscore.
import *
single_trailing_underscore_
: used by convention to avoid conflicts with
Python keyword, e.g.Tkinter.Toplevel(master, class_='ClassName')
__double_leading_underscore
: when naming a class attribute, invokes name
mangling (inside classFooBar
, __boo becomes_FooBar__boo
; see below).
__double_leading_and_trailing_underscore__
: “magic” objects or
attributes that live in user-controlled namespaces. E.g.__init__
,
__import__
or__file__
. Never invent such names; only use them
as documented.