Created
January 21, 2019 14:53
-
-
Save TimurNurlygayanov/cf382ce6681805443c32ca1c030268af to your computer and use it in GitHub Desktop.
parent_and_child_python2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class a(object): | |
__numbers = [1, 2, 3] | |
def input(self, numbers): | |
self.__numbers = numbers | |
def sum(self): | |
print(sum(self.__numbers)) | |
class b(a): | |
def sum_x2(self): | |
print(2 * sum(self.__numbers)) # this will NOT work | |
def sum_x2_renamed(self): | |
print(2 * sum(self._a__numbers)) # this will work fine | |
my_object = b() | |
my_object.input([1, 5, 10]) | |
my_object.sum_x2_renamed() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment