summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2023-11-25 22:20:53 (GMT)
committerGitHub <noreply@github.com>2023-11-25 22:20:53 (GMT)
commit97f8f28b3e50196f6713faceccc2e15039117470 (patch)
treebfb54e17d4928743c99185f8a677bb3e4d79aa05 /Doc
parentf93a4ef7a9e8d6f831c62707c0d39e0be306c4e6 (diff)
downloadcpython-97f8f28b3e50196f6713faceccc2e15039117470.zip
cpython-97f8f28b3e50196f6713faceccc2e15039117470.tar.gz
cpython-97f8f28b3e50196f6713faceccc2e15039117470.tar.bz2
gh-112331: Fix reference manual description of attribute lookup mechanics (gh-112375)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/expressions.rst18
1 files changed, 12 insertions, 6 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 14c2afa..3f6d5bf 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -823,12 +823,18 @@ An attribute reference is a primary followed by a period and a name:
The primary must evaluate to an object of a type that supports attribute
references, which most objects do. This object is then asked to produce the
-attribute whose name is the identifier. This production can be customized by
-overriding the :meth:`__getattr__` method. If this attribute is not available,
-the exception :exc:`AttributeError` is raised. Otherwise, the type and value of
-the object produced is determined by the object. Multiple evaluations of the
-same attribute reference may yield different objects.
-
+attribute whose name is the identifier. The type and value produced is
+determined by the object. Multiple evaluations of the same attribute
+reference may yield different objects.
+
+This production can be customized by overriding the
+:meth:`~object.__getattribute__` method or the :meth:`~object.__getattr__`
+method. The :meth:`!__getattribute__` method is called first and either
+returns a value or raises :exc:`AttributeError` if the attribute is not
+available.
+
+If an :exc:`AttributeError` is raised and the object has a :meth:`!__getattr__`
+method, that method is called as a fallback.
.. _subscriptions: