Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e5bcd1

Browse files
bpo-21196: Clarify name mangling rules in tutorial (GH-5667)
Initial patch by Chandan Kumar. (cherry picked from commit 13ae4d4) Co-authored-by: Berker Peksag <[email protected]>
1 parent c8348fb commit 3e5bcd1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Doc/tutorial/classes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,11 @@ breaking intraclass method calls. For example::
703703
for item in zip(keys, values):
704704
self.items_list.append(item)
705705

706+
The above example would work even if ``MappingSubclass`` were to introduce a
707+
``__update`` identifier since it is replaced with ``_Mapping__update`` in the
708+
``Mapping`` class and ``_MappingSubclass__update`` in the ``MappingSubclass``
709+
class respectively.
710+
706711
Note that the mangling rules are designed mostly to avoid accidents; it still is
707712
possible to access or modify a variable that is considered private. This can
708713
even be useful in special circumstances, such as in the debugger.

0 commit comments

Comments
 (0)