This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Documentation of attribute reference is unclear
Type: enhancement Stage:
Components: Documentation Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Dirk Herrmann, docs@python
Priority: normal Keywords:

Created on 2020-02-11 23:17 by Dirk Herrmann, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg361837 - (view) Author: Dirk Herrmann (Dirk Herrmann) Date: 2020-02-11 23:17
Trying to understand attribute reference in Python, I was lost:

* In the "Python Language Reference" (I will refer to this as PLR, sorry if that is uncommon, did not find an abbreviation in the glossary): Chapter 6.3.1 is about attribute reference.  How the attribute reference actually works is not explained in detail, only with the sentence "This object is then asked to produce the attribute whose name is the identifier." which I find vague.  Moreover, in PLR 6.3.1 it is said that it can be customized overriding "__getattr__()", but again, details are unclear.  And, when following the link to "__getattr__()" it turns out that "__getattr__()" is not called for attribute access, but only in certain circumstances:

* PLR 3.3.1 section "object.__getattr__(self, name)" explains that this is only called when "default attribute access" fails.  There is nowhere an explanation of "default attribute access", it is also not mentioned in the index.  There is some explanation in parentheses what it means if "default attribute access" fails, but the actual procedure of the "default attribute access" is still not clear.  A bit further down in this section it is also mentioned that if an attribute is found using the "normal mechanism" then "__getattr__()" is not called - again not explaining what the "normal mechanism" is.  There is some reference to "__getattribute__()" here, saying that with "__getattribute__()" there would be "total control over attribute access", but this leads again to confusion:

* PLR 3.3.1 section "object.__getattribute__(self, name)" indicates that this "may still be bypassed" in certain circumstances, referring to PLR 3.3.10, special method lookup, which refers to the "conventional lookup process", to which this is an exception.  The basis why this is an exception remains unclear - is it that certain method names are detected during attribute reference?

Summary: There is not (or I was too stupid to find) a concise description of how attribute reference works.  There are several terms used to refer to certain aspects of it: "default attribute access", "normal mechanism [of attribute access]", "conventional lookup process", which may or may not refer to the same thing, which seems not to be documented anyway.
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83795
2020-02-11 23:17:29Dirk Herrmanncreate