Python naming convention and the private attribute

Post date: Jul 29, 2016 4:31:28 PM

From [1],

- _single_leading_underscore: weak "internal use" indicator.  E.g. "from M

  import *" does not import objects whose name starts with an underscore.

- __double_leading_underscore: when naming a class attribute, invokes name

  mangling, i.e.

class SuperClass:

    __boo # becomes _SuperClass__boo

class SubClass(SuperClass):

    __boo # becomes _SubClass__boo # still a problem if SubClass === SuperClass

    self._SuperClass__boo # NOT RECOMMENDED!

[1] http://stackoverflow.com/questions/6930144/underscore-vs-double-underscore-with-variables-and-methods