Python 2.7 Descriptor -- What is "Binding Behavior"
Asked Answered
E

1

7

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?

Erechtheum answered 8/3, 2016 at 22:32 Comment(0)
O
6

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.

Osbourn answered 24/2, 2017 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.