Skip to content

gh-135676: Reword the f-string (and t-string) section #137469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

encukou
Copy link
Member

@encukou encukou commented Aug 6, 2025

Continuing from #135942, this tackles the f-string section.

Much of the information was duplicated in stdtypes.rst; this PR keeps lexical/syntactical details in Lexical Analysis and the evaluation & runtime behaviour in Standard types, with cross-references between the two.
Since the t-string section only listed differences from f-strings, and the grammar for the two is equivalent, that section was moved to Standard types almost entirely.


📚 Documentation preview 📚: https://cpython-previews--137469.org.readthedocs.build/

Comment on lines +2570 to +2572
>>> number = 14.3
>>> 'number=14.3'
number=14.3
Copy link
Member

@StanFromIreland StanFromIreland Aug 6, 2025

Choose a reason for hiding this comment

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

This example is wrong, maybe this was intended?:

Suggested change
>>> number = 14.3
>>> 'number=14.3'
number=14.3
>>> number = 14.3
>>> f'{number=}'
'number=14.3'

Comment on lines +2584 to +2585
By default, the value of a replacement field expression is converted to
string using :func:`str`::
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
By default, the value of a replacement field expression is converted to
string using :func:`str`::
By default, the value of a replacement field expression is converted to
a string using :func:`str`::

>>> f'{Fraction(1, 3)!s}'
For example::

>>> str(one_third)
Copy link
Member

Choose a reason for hiding this comment

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

These example are duplicated, how about merging it all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants