Greetings!
#!/usr/bin/python3 class Employee: """Class with FirstName, LastName, Salary""" def __init__(self, FirstName,LastName, Salary): self.FirstName = FirstName self.LastName = LastName self.Salary = Salary def __str__(self): return '("{}" "{}" "{}")'.format(self.FirstName, self.LastName, self.Salary) class Developer(Employee): """Define a subclass, augment with ProgLang""" def __init__(self, FirstName,LastName, Salary, ProgLang): Employee.__init__(self, FirstName,LastName, Salary) self.ProgLang = ProgLang def dev_repr(self): return '("{}" "{}" "{}" "{}")'.format(self.FirstName, self.LastName, self.Salary, self.ProgLang) a = Employee("Abigail", "Buchard", 83000) print(a) dev_1 = Developer("Samson", "Sue", 63000, "Cobol",) print(dev_1) print(dev_1.dev_repr()) running that yields, ("Abigail" "Buchard" "83000") ("Samson" "Sue" "63000") ("Samson" "Sue" "63000" "Cobol") My doubt is, how can we set the __str__ method work on the Employee subclass so that it would show ProgLang too, like the print(dev_1.dev_repr())? Thanks in advance! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor