[Python-checkins] bpo-21196: Clarify name mangling rules in tutorial (GH-5667)

Victor Stinner webhook-mailer at python.org
Fri Oct 19 20:33:51 EDT 2018

commit: 13ae4d44381a647aadd09b70b24833052659be41
branch: master
author: Berker Peksag <berker.peksag at gmail.com>
committer: Victor Stinner <vstinner at redhat.com>
date: 2018-10-20T02:33:48+02:00

bpo-21196: Clarify name mangling rules in tutorial (GH-5667)

Initial patch by Chandan Kumar.

M Doc/tutorial/classes.rst

diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 83b7db7c7cff..7d3b823a14e0 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -703,6 +703,11 @@ breaking intraclass method calls.  For example::
            for item in zip(keys, values):
+The above example would work even if ``MappingSubclass`` were to introduce a
+``__update`` identifier since it is replaced with ``_Mapping__update`` in the
+``Mapping`` class  and ``_MappingSubclass__update`` in the ``MappingSubclass``
+class respectively.
 Note that the mangling rules are designed mostly to avoid accidents; it still is
 possible to access or modify a variable that is considered private.  This can
 even be useful in special circumstances, such as in the debugger.

More information about the Python-checkins mailing list