python class definition reminder

Solutions on MaxInterview for python class definition reminder by the best coders in the world

showing results for - "python class definition reminder"
Anae
12 Sep 2017
1class Mapping:
2    def __init__(self, iterable):
3        self.items_list = []
4        self.__update(iterable)
5
6    def update(self, iterable):
7        for item in iterable:
8            self.items_list.append(item)
9
10    __update = update   # private copy of original update() method
11
12class MappingSubclass(Mapping):
13	# MappingSubclass inherits methods and attributes from Mapping
14    def update(self, keys, values):
15        # provides new signature for update()
16        # but does not break __init__()
17        for item in zip(keys, values):
18            self.items_list.append(item)
19