-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
F-strings docs: link to Format Specifiers #4888
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
Link to the Format Specification Mini Language section from f-strings' documentation.
|
Thanks @Mariatta for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
Link to the Format Specification Mini Language section from f-strings' documentation. (cherry picked from commit d924fa5)
|
GH-4889 is a backport of this pull request to the 3.6 branch. |
| Top-level format specifiers may include nested replacement fields. | ||
| These nested fields may include their own conversion fields and | ||
| format specifiers, but may not include more deeply-nested replacement fields. | ||
| :ref:`format specifiers <formatspec>`, but may not include more |
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.
great addition, but it would also be good to explicitly state, without having to follow a link, that f-strings use the same format mini-langage as the .format() method. Maybe:
These nested fields may include their own conversion fields and format specifiers, but may not include more deeply-nested replacement fields. The :ref:format specifier mini-language <formatspec> is the same as that used by the string .format() method.
maybe put the ref in the seconds sentence?
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.
Makes sense :) I'll make another PR later today.
|
Are f-strings only documented in the lexical analysis part of the language reference? I"m not sure newbies will find that. They should probably be mentioned here: https://docs.python.org/3/library/stdtypes.html?highlight=string%20literal#text-sequence-type-str I do see a link to the string literal page of lexical analysis there, so if it's at least mentioned, that may do it. maybe: """ |
|
Yes this is indeed the documentation for f-strings. |
Link to the Format Specification Mini Language section from f-strings' documentation.