python - Using Composition instead of inheritance -


i new python , have been trying use composition instead of inheritance code below no avail have tried job_cls =job in permanent class gives me access method in job class.i cannot seem access attributes , methods of job class via permanent class using composition.i have looked @ countless videos , blogs online of them refer attribute self.l1= job(location) in permanent class.your appreciated.

class job:        def __init__(self, location, salary, description, fee):          self.location = location             self.salary = salary             self.description = description           self.fee = fee        def charge(self):            if self. fee > 1000 :                print("sell")            else:                print("reject")       def charge2(self):           self.salary = int(self.salary * self.rate)     class permanent(job):        rate =1.05     permanent1 = permanent("london", 23000, "accounts assistant", 1200)  permanent1.rate=1.06     permanent1.charge2()     print(permanent1.salary)  


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -