By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,584 Members | 3,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,584 IT Pros & Developers. It's quick & easy.

Private copy of method in Python base class

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

Expand|Select|Wrap|Line Numbers
  1. class Mapping:
  2.     def __init__(self, iterable):
  3.         self.items_list = []
  4.         self.__update(iterable)
  5.     def update(self, iterable):
  6.         for item in iterable:
  7.             self.items_list.append(item)
  8.     __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?
Nov 20 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.