Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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__`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:meth:`~object.__getattribute__` method or the :meth:`~object.__getattr__`
:meth:`~object.__getattribute__` method and/or the :meth:`~object.__getattr__`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "or" is fine. The "and/or" is correct but looks weird and doesn't read well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that it looks weird, but won't insist

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:

Expand Down