Author Devin Jeanpierre
Recipients Devin Jeanpierre, docs@python
Date 2010-12-25.05:05:49
SpamBayes Score 5.51989e-10
Marked as misclassified No
Message-id <>
In trunk/Doc/reference/datamodel.rst , under _Implementing Descriptors_, the documentation states: 

`The following methods only apply when an instance of the class containing the method (a so-called *descriptor* class) appears in the class dictionary of another new-style class, known as the *owner* class. [...]`

Immediately below, in the documentation for __get__, it says, `*owner* is always the owner class [...]`.

These two uses of "the owner class" are incompatible, because there is only one class which matches the first use: the class where the descriptor was initially assigned to a class attribute; however, for the second use, any descendant class may be called "the owner class". This is demonstrated in the attached doctest file.

It is kind of hard to create a better definition for "owner" as used in `__get__`, though. It can't be said to be the class with the descriptor in its class dict, because it can be present in the class dict of some class in the MRO of the owner. It can't be said to be an attribute, because it has to be in a class dict of an ancestor node.

It might be possible to change the definition to call the owner class something like, "the class from which the descriptor was invoked", and if that isn't clear enough, provide examples (TypeDescriptor from the attached doctest file might work as an example); however, this would involve reworking the structure of the paragraph substantially. I personally would prefer this option. The paragraph is already badly structured; for example, it defines two terms in a single and rather complex sentence, and should probably be split up into a list of definitions rather than an explanatory jumble paragraph. In addition, this paragraph is the only place in the documentation where this idea of "the owner class" is used in this way. In the descriptions of the descriptor protocol methods below it, "the owner class" always refers to the class from which the attribute was accessed, or the type from which an instance had the attribute accessed.

Alternatively, it could be simpler to replace all references below from "the owner class" to "any class with the owner class in the MRO".
Date User Action Args
2010-12-25 05:05:54Devin Jeanpierresetrecipients: + Devin Jeanpierre, docs@python
2010-12-25 05:05:54Devin Jeanpierresetmessageid: <>
2010-12-25 05:05:50Devin Jeanpierrelinkissue10771 messages
2010-12-25 05:05:50Devin Jeanpierrecreate