2 Jul
2020
2 Jul
'20
10:04 a.m.
02.07.20 10:12, Greg Ewing пише:
The @property.getter and @property.setter decorators are clever, but they have the disadvantage that you end up writing the name of the property no less than 5 times, all of which have to match.
5 times? How is it?
Thinking there must be a better way, I came up with this:
def Property(name, bases, dict): return property(dict.get('get'), dict.get('set'))
It has a problem with pickling (it is solvable). The larger problem is with using private (double underscored) variables and super().