Q:

Clean way to implement setter and getter for lots of properties?

I have known the use of setter and getter for several properties, how could I trigger a same function when any property changes?
For example, the following codes add a setter to property a. 
class AAA(object):
    def __init__(self):
        ...
    @property
    def a(self):
        ...
    @a.setter
    def a(self, value):
        ...

If the class has a lot of properties like a, b, ... , z, and I want to print something like property xxx is modified when any property changes.
It is stupid to add the similar getter and setter one by one.
I have read some related questions and answers, but I do not find the solution for many properties.

How to trigger function on value change?
Using @property versus getters and setters

A:

Metaprogramming, using __setattr__ to intercept modification:
class AAA(object):
    def __setattr__(self, attr, value):
        print("set %s to %s" % (attr, value))
        super().__setattr__(attr, value)

aaa = AAA()
aaa.x = 17
# => set x to 17
print(aaa.x)
# => 17

You can do similarly with __getattr__ for reading access.

