Skip to content

Commit 07f968d

Browse files
committed
pythongh-112331: Fix reference manual description of attribute lookup mechanics
1 parent e9d1360 commit 07f968d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Doc/reference/expressions.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,17 @@ An attribute reference is a primary followed by a period and a name:
823823

824824
The primary must evaluate to an object of a type that supports attribute
825825
references, which most objects do. This object is then asked to produce the
826-
attribute whose name is the identifier. This production can be customized by
827-
overriding the :meth:`__getattr__` method. If this attribute is not available,
828-
the exception :exc:`AttributeError` is raised. Otherwise, the type and value of
829-
the object produced is determined by the object. Multiple evaluations of the
830-
same attribute reference may yield different objects.
826+
attribute whose name is the identifier. The type and value produced is
827+
determined by the object. Multiple evaluations of the same attribute
828+
reference may yield different objects.
831829

830+
This production can be customized by overriding the :meth:`__getattribute__`
831+
method or the :meth:`__getattr__` method. The :meth:`__getattribute__`
832+
is called first and either returns a value or raises :exc:`AttributeError`
833+
if the attribute is not available.
834+
835+
If an :exc:`AttributeError` raised and the object has a :meth:`__getattr__`
836+
method, that method is called as a fallback.
832837

833838
.. _subscriptions:
834839

0 commit comments

Comments
 (0)