423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 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
  9.  
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?
3 Weeks Ago #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.