summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial/classes.rst
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-07-29 01:11:09 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-07-29 01:11:09 (GMT)
commit2527796a22404d5b8cb0e498a965c6b4a743caac (patch)
tree5bc07b91dde0085cc09c3336ed740f6817f11fc3 /Doc/tutorial/classes.rst
parent1e3a68d36b08cd9d59084a37c8cb6c2d911868ce (diff)
parentcf534817adc49b2562d175fabd3e3992d25063fe (diff)
downloadcpython-2527796a22404d5b8cb0e498a965c6b4a743caac.zip
cpython-2527796a22404d5b8cb0e498a965c6b4a743caac.tar.gz
cpython-2527796a22404d5b8cb0e498a965c6b4a743caac.tar.bz2
Merge from 3.2 (#10318, #12255, #12043, #12417 and other fixes)
Diffstat (limited to 'Doc/tutorial/classes.rst')
-rw-r--r--Doc/tutorial/classes.rst28
1 files changed, 14 insertions, 14 deletions
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 336d074..4926280 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -598,24 +598,24 @@ occurs within the definition of a class.
Name mangling is helpful for letting subclasses override methods without
breaking intraclass method calls. For example::
- class Mapping:
- def __init__(self, iterable):
- self.items_list = []
- self.__update(iterable)
+ class Mapping:
+ def __init__(self, iterable):
+ self.items_list = []
+ self.__update(iterable)
- def update(self, iterable):
- for item in iterable:
- self.items_list.append(item)
+ def update(self, iterable):
+ for item in iterable:
+ self.items_list.append(item)
- __update = update # private copy of original update() method
+ __update = update # private copy of original update() method
- class MappingSubclass(Mapping):
+ class MappingSubclass(Mapping):
- def update(self, keys, values):
- # provides new signature for update()
- # but does not break __init__()
- for item in zip(keys, values):
- self.items_list.append(item)
+ def update(self, keys, values):
+ # provides new signature for update()
+ # but does not break __init__()
+ for item in zip(keys, values):
+ self.items_list.append(item)
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