0

Some value is calculated in instance variable of parent class which is being used in child class.

I want to make that variable private in child class. Is It possible.

example problem:

class _person:                   # A private function just for fetching results
     def __init__(self, name, age):
         self.name= name
         self.age= age
         self.salary= self.salary()            # some method to fetch salary
         self.address= self.address()          # some method to fetch address

class child(_person):
     def __init__(self, name, age):
         super(child,self).__init__(name, age)


emp= child(name, age)

I want to restrict the use of emp.salary by making it private in child class.

Is it possible???

Thank You soo much

0 Answers0