Say we have 10 attributes:
class test(object):
def __init__(self,a,b,c,d,e,f,g,h,i,j):
self._a = a
#the same with the rest of variables
Is it possible to make them all properties?:
@property
def a(self):
return self.a
@a.setter
def a(self,a_new):
#invoke other functions doing other stuff when attribute values change
self._a = a_new
If I need the same functions to run when any instance attribute is changed, do I have to type the above code for each attribute? Is it possible to write the code once then use it as a custom decorator or something similar?
If the custom decorator is the way to go, can I afterwards override the setter function for some attributes?