class Primary(): def __init__(self, param1, param2): self.param1 = param1 self.__param2 = param2 def getP1(self): return self.param1 def getP2(self): return self.__param2 class Secondary(Primary): def __init__(self, param1, param2, param3): Primary.__init__(self, param1, param2) self.__param3 = param3 def getP3(self): return self.__param3 def test(self): print (self.getP2()) #Main p = Primary('a', 'b') s = Secondary('a', 'b', 'c') s.test()
Inheritance private attributes
Messages In This Thread |
Inheritance private attributes - by vaison - May-02-2018, 08:18 PM
RE: Inheritance private attributes - by Larz60+ - May-02-2018, 08:29 PM
RE: Inheritance private attributes - by vaison - May-02-2018, 08:56 PM
RE: Inheritance private attributes - by ThiefOfTime - May-02-2018, 09:04 PM
RE: Inheritance private attributes - by snippsat - May-02-2018, 09:06 PM
RE: Inheritance private attributes - by vaison - May-03-2018, 09:22 AM
|
Users browsing this thread: 1 Guest(s)