Skip to content

Conversation

@Mariatta
Copy link
Member

Link to the Format Specification Mini Language section from f-strings' documentation.

Link to the Format Specification Mini Language section from f-strings' documentation.
@miss-islington
Copy link
Contributor

Thanks @Mariatta for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@Mariatta Mariatta deleted the Mariatta-patch-1 branch December 15, 2017 18:07
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 15, 2017
Link to the Format Specification Mini Language section from f-strings' documentation.
(cherry picked from commit d924fa5)
@bedevere-bot
Copy link

GH-4889 is a backport of this pull request to the 3.6 branch.

Mariatta pushed a commit that referenced this pull request Dec 15, 2017
Link to the Format Specification Mini Language section from f-strings' documentation.
(cherry picked from commit d924fa5)
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
Copy link
Contributor

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?

Copy link
Member Author

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.

@ChrisBarker-NOAA
Copy link
Contributor

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:

"""
See :refString and Bytes literals <proper ref here> for more about the various forms of string literal, including supported escape sequences, the r (“raw”) prefix that disables most escape sequence processing, and the f (f-string) prefix that provides :ref:formatted string literals <ref_to_formatted_sring_literals_section>.

@Mariatta
Copy link
Member Author

Yes this is indeed the documentation for f-strings.
It is referenced from PEP 498's section in What's New in Python 3.6.
f-string is also a terminology in the Glossary, linking back to this page.

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 issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants