Python Forum
Inheritance private attributes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inheritance private attributes
#2
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()
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Lint and private var names PatM 1 731 Dec-15-2022, 05:08 PM
Last Post: deanhystad
  Unable to import Private Repo using setup.py Bob786 1 1,793 Sep-02-2021, 04:19 PM
Last Post: snippsat
  python 3 dns lookup private domain didact 1 2,625 Sep-19-2020, 06:01 PM
Last Post: bowlofred
  [split] Помощь по приватным ключам/Private key help sairam17519 0 1,630 Sep-07-2020, 12:55 PM
Last Post: sairam17519
  Download file from Private GitHub rep vinuvt 0 2,011 Jul-27-2020, 11:38 AM
Last Post: vinuvt
  Private package distribution abomination disadvantages research andreir 2 2,204 May-07-2020, 12:32 AM
Last Post: andreir
  Помощь по приватным ключам/Private key help vlrubl777 5 6,085 Mar-15-2019, 08:16 PM
Last Post: vlrubl777
  when to make attributes private? sneakyimp 10 6,071 Jan-21-2019, 02:54 PM
Last Post: sneakyimp
  Fetching private ip address from instances of an autoscaling group deepsonune 0 3,312 May-18-2018, 10:32 AM
Last Post: deepsonune
  Class Attributes Inheritance Harry_Potter 3 3,909 Nov-16-2017, 07:01 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020