Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Multiline expression brackets with format specifiers don't work in f-strings #110259

Closed
Assignees
pablogsallysnikolaou
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or error
@tusharsadhwani

Description

@tusharsadhwani

Bug report

Bug description:

In accordance withPEP 701, the following code works:

>>> x=1>>>f"___{...     x... }___"'___1___'>>>f"___{(...     x... )}___"'___1___'

But the following fails:

f"__{x:d}__"

This gives:

  File "<stdin>", line 1    x:dSyntaxError: unterminated f-string literal (detected at line 2)

Is this intended behaviour? This is not clarified in the PEP.


Similarly,

f"""__{x:d}__"""

Gives:

Traceback (most recent call last):  File "<stdin>", line 1, in <module>ValueError: Invalid format specifier 'd' for object of type 'int'

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp