You have seen the regular class methods of the class. The regular method automatically takes an instance as the first argument, and, by convention, we called it self. How can we pass the class as an argument so that we can change the class variable in the method? To do that, we use the class method. The class method takes the class as first argument. To turn the regular method into the class method, we will use decorator (@classmethod) at the top of the method. Let's see the methodclass1.py example:
class Leapx_org():
mul_num = 1.20
def __init__(self,first,last,pay):
self.f_name = first
self.l_name = last
self.pay_amt = pay
self.full_name = first+" "+last
def make_email(self):
return self.f_name+ "."+self.l_name+"@xyz.com"
def incrementpay(self):
self.pay_amt = int(self.pay_amt*self.mul_num)
...