bpo-20751: Clarify descriptor #30271
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I fear that the section "invoking descriptor" was quite hard to grasp. I try to improve this with the following changes.
The notion of lookup chain was used without ever being defined anywhere in the
documentation. I add a short definition.
was changed. It seemed to indicate that descriptor replace the behavior
described previously, of checking for the value associated to
x
ina
in thelookup chain. To the best of my understanding, the lookup chain is still used,
since we do not even know whether
x
is a descriptor or not until the lookupchain returned a value. It would be more exact to indicate that a descriptor
override the action of returning, assigning or deleting.
While #29909 was a net improvement, I fear it was not sufficient. I had three
issues while reading this section for a first time.
a.x
(that's the very pointof the direct call), so the Direct Call should not have been in this
enumeration. In fact, what is even worse is that in the Direct Call,
x
is avariable while in all other case,
x
is an attribute name.was called
a
in the introduction of the list is now calledsuper(A, a)
. Atthis point, I believe it is more clear to just state that there are four ways to
invoke a descriptor and to list them. Each case introducing the variables it
requires.pp
documentation uses "attribute access". This lead me to assume that there is a
reason why a different name was used, that it was referencing a different
concept. I believe it is best to be consistent with naming of a concept.
B
followingA
" was slightly confusing,as it seems to indicates that there may exists multiple such base class
B
. Ibelieve that "the base class
B
" is clearer.For your information "dotted lookup" is also used in the howto section; I'd
suggest to change it there too for the sake of consistency. But since the usage
is consistent throughout the howto's descriptor file, this is at least less
confusing than this usage.
https://bugs.python.org/issue20751