Skip to content

gh-81039: Add small description of f-string's "=}" to tutorial#92291

Merged
ericvsmith merged 2 commits into
python:mainfrom
slateny:s/fstring
Sep 21, 2022
Merged

gh-81039: Add small description of f-string's "=}" to tutorial#92291
ericvsmith merged 2 commits into
python:mainfrom
slateny:s/fstring

Conversation

@slateny

@slateny slateny commented May 4, 2022

Copy link
Copy Markdown
Contributor

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, is this the best example? The main use case for this feature is for debugging, and there doesn't really seem to be any debugging going on in this example.

@AlexWaygood AlexWaygood requested a review from ericvsmith May 4, 2022 12:24
Comment thread Doc/tutorial/inputoutput.rst Outdated
@slateny

slateny commented May 5, 2022

Copy link
Copy Markdown
Contributor Author

Hmm, is this the best example? The main use case for this feature is for debugging, and there doesn't really seem to be any debugging going on in this example.

Maybe something like

bugs = 'roaches'
count = '13'
area = 'living room'
print(f'Debugging: {bugs=} {count=} {area=}')
...

And this tutorial section could possibly also use an example for printing the curly brackets too

... And you can escape curly brackets in f-strings by using two:

...
print(f'Debugging: {{{bugs=} {count=} {area=}}}')
...

@ambv

ambv commented May 19, 2022

Copy link
Copy Markdown
Contributor

The last example you provided is very nice. I would split the example of showing {{ into a separate one so that newbies won't confuse themselves into thinking that {= requires triple braces.

@ericvsmith

Copy link
Copy Markdown
Member

The last example you provided is very nice. I would split the example of showing {{ into a separate one so that newbies won't confuse themselves into thinking that {= requires triple braces.

It is a good example, except I'd make count an integer, not a string. And I'd omit the {{ example entirely, because it's orthogonal to this and covered elsewhere.

@ericvsmith ericvsmith merged commit 4b81139 into python:main Sep 21, 2022
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @slateny for the PR, and @ericvsmith for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-96989 is a backport of this pull request to the 3.11 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 21, 2022
…hongh-92291)

(cherry picked from commit 4b81139)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
@bedevere-bot bedevere-bot removed needs backport to 3.11 only security fixes needs backport to 3.10 only security fixes labels Sep 21, 2022
@bedevere-bot

Copy link
Copy Markdown

GH-96990 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 21, 2022
…hongh-92291)

(cherry picked from commit 4b81139)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
ericvsmith pushed a commit that referenced this pull request Sep 21, 2022
…gh-96990)

(cherry picked from commit 4b81139)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
ericvsmith pushed a commit that referenced this pull request Sep 21, 2022
…gh-96989)

(cherry picked from commit 4b81139)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
@slateny slateny deleted the s/fstring branch September 24, 2022 03:51
pablogsal pushed a commit that referenced this pull request Oct 22, 2022
…gh-96989)

(cherry picked from commit 4b81139)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants