Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Merged
merged 2 commits into from
Sep 21, 2022

Conversation

slateny
Copy link
Contributor

@slateny slateny commented May 4, 2022

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels May 4, 2022
@slateny slateny added skip news needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels May 4, 2022
Copy link
Member

@AlexWaygood AlexWaygood left a comment

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
@slateny
Copy link
Contributor Author

slateny commented May 5, 2022

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
Copy link
Contributor

ambv commented May 19, 2022

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
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.

@serhiy-storchaka serhiy-storchaka added needs backport to 3.11 only security fixes and removed needs backport to 3.9 only security fixes labels May 20, 2022
@ericvsmith ericvsmith merged commit 4b81139 into python:main Sep 21, 2022
@miss-islington
Copy link
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

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
@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

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
ericvsmith pushed a commit that referenced this pull request Sep 21, 2022
ericvsmith pushed a commit that referenced this pull request Sep 21, 2022
@slateny slateny deleted the s/fstring branch September 24, 2022 03:51
pablogsal pushed a commit that referenced this pull request Oct 22, 2022
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