Skip to content
Open
Changes from 1 commit
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
15 changes: 8 additions & 7 deletions Doc/library/string.templatelib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,14 @@ Types
.. attribute:: expression
:type: str

The text of a valid Python expression, or an empty string.

The :attr:`.expression` is the original text of the
interpolation's Python expression, if the interpolation was created
from a t-string literal. Developers creating interpolations manually
should either set this to an empty string or choose a suitable valid
Python expression.
For interpolations created from t-string literals, :attr:`!expression`
is the source text found inside the curly braces, including any
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
is the source text found inside the curly braces, including any
is the source text found inside the curly brackets (``{`` & ``}``), including any

Copy link
Contributor Author

@davepeck davepeck Sep 21, 2025

Choose a reason for hiding this comment

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

Aren't they "curly braces", not "brackets"?

(Or is there some python doc standard here?)

Copy link
Contributor Author

@davepeck davepeck Sep 21, 2025

Choose a reason for hiding this comment

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

Update: haha, I checked, and it looks like there's no consistency even in the Python docs.

Here's a google search for "curly braces" in Python docs vs same search for "curly brackets"

Top Google hit for "curly braces" in the docs is inside Format String Syntax

Top Google hit for "curly brackets" in the docs is in the index itself

Happy to go either way here! 🤷🏻‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

@davepeck I'd use 'curly brackets', it's how we refer to them in the index.

whitespace, but excluding the curly braces themselves. For manually
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
whitespace, but excluding the curly braces themselves. For manually
whitespace, but excluding the curly brackets themselves. For manually

created interpolations, :attr:`!expression` is an arbitrary string.

It is recommended that developers manually creating
:class:`!Interpolation` instances use valid Python expressions or leave
the string empty, but this is not enforced.

>>> t'{1 + 2}'.interpolations[0].expression
'1 + 2'
Expand Down
Loading