I cannot find a proper way of decorating a @property.setter decorator inside a Python class.
To avoid copy-pasting of code, I decided to decorate @property.setter function in my project's "Settings" module. So "Setting" module, has an ability of auto-saving newly added/changed settings.
The issue is that to enable auto-saving ability I have to set a certain flag:
self.changed = True
every time a setting is modified.
But, I don't think that adding that flag to every @property.setter is a good idea, since there might be a case when I have to do more logic before save is performed, and in that case I will have to paste this logic to every @property.setter I already have (which is not efficient imo).
What I want is to replace:
@baud_rate.setter
def baud_rate(self, value):
self.changed = True
self._baud_rate = value
with:
@setting_decorator
@baud_rate.setter
def baud_rate(self, value):
self._baud_rate = value
But I have no clue on how to implement such decorator.