GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — f-string documentation not fully accurate · Issue #81997 · python/cpython

f-string documentation not fully accurate #81997

New issue
Copy link
New issue
Copy link
Closed
#137469
Closed
f-string documentation not fully accurate#81997
#137469
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

vpython
mannequin
opened on Aug 11, 2019
Issue body actions
BPO 37816
Nosy @ericvsmith

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2019-08-11.01:06:41.829>
labels = ['3.7', '3.8', '3.9', 'docs']
title = 'f-string documentation not fully accurate'
updated_at = <Date 2019-08-11.03:17:56.205>
user = 'https://bugs.python.org/vpython'

bugs.python.org fields:

activity = <Date 2019-08-11.03:17:56.205>
actor = 'xtreak'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2019-08-11.01:06:41.829>
creator = 'v+python'
dependencies = []
files = []
hgrepos = []
issue_num = 37816
keywords = []
message_count = 1.0
messages = ['349370']
nosy_count = 3.0
nosy_names = ['eric.smith', 'v+python', 'docs@python']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue37816'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9']

Activity

  1. vpython commented on Aug 11, 2019

    @vpython
    vpythonmannequin
    on Aug 11, 2019
    MannequinAuthor
    More actions

    I noticed the following description for f-strings:

    Escape sequences are decoded like in ordinary string literals (except when a literal is also marked as a raw string). After decoding, the grammar for the contents of the string is:

    followed by lots of stuff, followed by

    Backslashes are not allowed in format expressions and will raise an error:
    f"newline: {ord('\n')}" # raises SyntaxError

    If f-strings are processed AS DESCRIBED, the \n would never seen by the format expression... but in fact, it does produce an error.

    PEP-498 has a more accurate description, that the {} parsing actually happens before the escape processing. The string or raw-string escape processing is done only to the literal string pieces.

    So the string content is first parsed for format expressions enclosed in {}, on the way, converting {{ and }} to { and } in the literal parts of the string, and then the literal parts are treated exactly like independent string literals (with regular or raw-string escaping performed), to be concatenated with the evaluation of the format expressions, and subsequent literal parts.

    The evaluation of the format expressions presently precludes the use of # and \ for comments and escapes, but otherwise tries to sort of by the same as a python expression possibly followed by a format mini-language part. I am not the expert here, just the messenger.

  2. vpython
    added
    3.7 (EOL)end of lifeend of life
    3.8 (EOL)end of lifeend of life
    3.9 (EOL)end of lifeend of life
    on Aug 11, 2019
  3. vpython
    assigned
    docspython
    on Aug 11, 2019
  4. vpython
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Aug 11, 2019
  5. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  6. iritkatriel commented on Apr 4, 2023

    @iritkatriel
    iritkatriel
    on Apr 4, 2023
    Member
    More actions

    CC @ericvsmith .

  7. ericvsmith commented on Apr 4, 2023

    @ericvsmith
    ericvsmith
    on Apr 4, 2023
    Member
    More actions

    I'd be open to a PR to address this, but I don't think it's causing a lot of confusion in the wild.

  8. iritkatriel
    added
    3.11only security fixesonly security fixes
    3.10 (EOL)end of lifeend of life
    3.12only security fixesonly security fixes
    and removed
    3.9 (EOL)end of lifeend of life
    3.8 (EOL)end of lifeend of life
    3.7 (EOL)end of lifeend of life
    on Apr 4, 2023
  9. StanFromIreland commented on Aug 12, 2025

    @StanFromIreland
    StanFromIreland
    on Aug 12, 2025
    Member
    More actions

    CC @encukou

    Reacted by Petr Viktorin
  10. StanFromIreland
    removed
    3.11only security fixesonly security fixes
    3.10 (EOL)end of lifeend of life
    3.12only security fixesonly security fixes
    on Aug 12, 2025
  11. github-project-automation
    added this to docs issueson Aug 12, 2025
  12. github-project-automation
    moved this to Todo in docs issueson Aug 12, 2025
  13. encukou commented on Aug 12, 2025

    @encukou
    encukou
    on Aug 12, 2025
    Member
    More actions

    See #137469

    Reacted by Stan Ulbrych
  14. StanFromIreland
    linked a pull request that will close this issuegh-135676: Reword the f-string (and t-string) section #137469on Aug 12, 2025
  15. encukou
    closed this as completedin #137469on Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    • docs issues
      Status
      Todo
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.