This is the first time I've understood descriptors. The article mentioned that it's hard to find examples in open source projects, are there any at all?
I believe that Kivy Properties are descriptors (though I've never heard them termed as such). Once you've defined, say:
class MyClass(EventDispatcher):
a = BoundedNumericProperty(1, min=0, max=100)
A call to " myClassInstance.a = 50 " will be validated. Though validation was not the primary goal; Kivy's properties are bindable and any observers of the Property will now be alerted about the change.
A special DSL called .kv makes those properties reactive, so you can compose expressions that reference them and derive new values. It's pretty cool.
2
u/dollars2donuts Jun 19 '13
This is the first time I've understood descriptors. The article mentioned that it's hard to find examples in open source projects, are there any at all?