Class function method in python

 class Employee:

    profession="Networking"
    def __init__(selfanameasalaryarole):
        self.name = aname
        self.role = arole
        self.salary = asalary

    def printdetails(self):
        return F"Name is {self.name} Salary is {self.salary} and role is {self.role}"

    @classmethod
    def change_profession(cls,  newprofessional):
        cls.profession = newprofessional



umair = Employee("Umair"344"Instructor")
umair.change_profession("Developer")
print(umair)

Comments