not able to define variable inside of decorated method
#Not exactly sure why the code is always using 1.2 when I redefine raise_percentage raise_percentage=1.2 class worker: def __init__(self,age,pay): self.age=age self.pay=pay def Raise(func): def wrapper(self): #as you can see I define raise_percentage by the amount I want to increase #wage by but it always refers back to the initial value 1.2. if self.age<30: raise_percentage=1.2 func(self) print("under 30") elif self.age<40: raise_percentage=1.1 func(self) print("under 40") elif self.age<50: raise_percentage=1.05 func(self) print("under 50") else: raise_percentage=1 func(self) print("over 50") return wrapper def func(self): print( self.pay*raise_percentage) Raised=Raise(func) Bob=worker(24,20000) Carl=worker(36,34000) Jessica=worker(43,41000) Jessica.Raised()