Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 Descriptor -- What is "Binding Behavior"

In the Python 2.7 documentation on Descriptors in the Introduction the phrase binding behavior is used.

In general, a descriptor is an object attribute with “binding behavior”, one whose attribute access has been overridden by methods in the descriptor protocol. Those methods are get(), set(), and delete(). If any of those methods are defined for an object, it is said to be a descriptor.

I am seeking a clear explanation of "binding behavior?" Is the word "one" referring to the word object? If that is the case then a descriptor is an object attribute that has been overridden by methods in a descriptor. Seems to be a recursive definition. Is binding behavior the ability to be assigned to an object member?

like image 913
mba12 Avatar asked Mar 08 '16 22:03

mba12


1 Answers

I just recently was reading the same article you were. And while I am almost a year late, I believe what it means is a developer can define behavior and then bind it to a given property. In respect to descriptors, this basically means binding the way a value can be set, queried or deleted for a given variable/object/data set. This interaction is 'bound' to this piece of data as in it only applies to what data you've set it on.

like image 147
Turk Avatar answered Sep 23 '22 03:09

Turk