Since there is a valid use-case for class-private members (namely to avoid name clashes of names with names defined by subclasses), there is limited support for such a mechanism, called :dfn:`name mangling`.Any identifier of the form ``__spam`` (at least two leading underscores, at most one trailing underscore) is textually replaced with ``_classname__spam``, where ``classname`` is the current class name with leading underscore(s) stripped.This mangling is done without regard to the syntactic position of the identifier, as long as it occurs within the definition of a class.
Since there is a valid use-case for class-private members (namely to avoid name clashes of names with names defined by subclasses), there is limited support for such a mechanism, called :dfn:`name mangling`.Any identifier of the form ``__spam`` (at least two leading underscores, at most one trailing underscore) is textually replaced with ``_classname__spam``, where ``classname`` is the current class name with leading underscore(s) stripped.This mangling is done without regard to the syntactic position of the identifier, as long as it occurs within the definition of a class.