Private copy of method in Python base class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • c0d3rX
    New Member
    • Nov 2018
    • 7

    Private copy of method in Python base class

    There is an example of code in Python documentation as follows:

    Code:
    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)
    	__update = update #private copy of original update () method
    In the last line of code is the comment #private copy of original update(). According to the literature, this is supposed to create a private copy of the update method in the base class in case an update method is created in a sub class.

    Does anyone have any insight on the significance of doing this?
Working...