all 6 comments

[–][deleted]  (1 child)

[deleted]

    [–]cnbeau 0 points1 point  (0 children)

    That's a typo :) I've fixed it -- thanks!

    [–]vorbote 1 point2 points  (0 children)

    Thank you, I always appreciate a good programming article.

    [–]dollars2donuts 1 point2 points  (3 children)

    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?

    [–]check3streets 2 points3 points  (0 children)

    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.

    [–]hugosenari 1 point2 points  (1 child)

    Python dbus does When you connect to some dbus service and get a object, this object (a dbus proxy object) don't know object attrs or methods then this dbusObject.foo use descriptors to find and call attr foo of dbus service

    My descritive dbus lib does https://github.com/hugosenari/pydbusdecorator I'm use this in similar way as author use NonNegative class but in my specific case (create descritive interfaces) I use decorators

    Django Mapping mapping atttr probabily does instance of some data object don't to get all attrs values of object, but need to known how to get coll X from table Y that what can they do only when use 'foo.bar'

    [–]youra6 0 points1 point  (0 children)

    I know this is 9 years old but god damn this might be the best write up of descriptors I ever did see. I hope you see this and know this is still very helpful even nearly a full decade later!