From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 20 Oct 2018 00:43:35 +0000 (-0700) Subject: bpo-21196: Clarify name mangling rules in tutorial (GH-5667) X-Git-Tag: v3.6.8rc1~206 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=efc09a9701543f7180fc7ea0b6c45cf198c29cb8;p=thirdparty%2FPython%2Fcpython.git bpo-21196: Clarify name mangling rules in tutorial (GH-5667) Initial patch by Chandan Kumar. (cherry picked from commit 13ae4d44381a647aadd09b70b24833052659be41) Co-authored-by: Berker Peksag --- diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index f26838cddbfa..487d535e169b 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): self.items_list.append(item) +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.