diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2018-10-20 00:33:48 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-20 00:33:48 (GMT) |
commit | 13ae4d44381a647aadd09b70b24833052659be41 (patch) | |
tree | d64740837ff51b66abab312ca49bf2e158cad507 /Doc | |
parent | 834603112e6ca35944dd21105b01fca562dc3241 (diff) | |
download | cpython-13ae4d44381a647aadd09b70b24833052659be41.zip cpython-13ae4d44381a647aadd09b70b24833052659be41.tar.gz cpython-13ae4d44381a647aadd09b70b24833052659be41.tar.bz2 |
bpo-21196: Clarify name mangling rules in tutorial (GH-5667)
Initial patch by Chandan Kumar.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tutorial/classes.rst | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 83b7db7..7d3b823 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. |