-
-
Notifications
You must be signed in to change notification settings - Fork 34k
bpo-41045: Add documentation for f-string's self documenting expressions #21464
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
Conversation
Missing documentation describing the = specifier for f-strings has been added
| >>> foo.__doc__ is None | ||
| True | ||
|
|
||
| F-strings can also help with "printf-style" debugging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to at least describe the feature. See my 2 points in bpo-41045 for what I think needs to be included.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Added more examples to explain f-string's self documenting expressions when format specifiers are used
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @ericvsmith: please review the changes made to this pull request. |
Corrected typos with single and double quotes in the f-string's examples
ericvsmith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this still needs some polishing, but I'm not very good at writing documentation. Hopefully someone else will respond with some suggestions.
amaajemyfren
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the line
replacement_field: "{" `f_expression` ["!" `conversion`] [":" `format_spec`] "}"Should be changed to
replacement_field: "{" `f_expression` ["="] ["!" `conversion`] [":" `format_spec`] "}"| >>> foo.__doc__ is None | ||
| True | ||
|
|
||
| F-strings can also help with "printf-style" debugging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rishi93,
Would you consider adding that this is new from version 3.8?
| Optional format specifiers can be placed after the equals sign. | ||
| If no format specifiers are used then :meth:`repr` is used on the expression. | ||
| If format specifier (like :20) is given, then :meth:`str` is used on the | ||
| expression. You can use the repr() with the !r format specifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rishi93,
I think !r is a conversion not a format specifier.
|
Hey @rishi93 and @ericvsmith, I have done this file and would like to hear your view of it. I was thinking of doing a PR of it but wanted your opinions first. |
|
@amaajemyfren, I will close this PR, you can open a new PR with your changes. Thank you for your effort. |
Missing documentation describing the = specifier for f-strings has been added
https://bugs.python.org/issue41045