This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: f-string behavior is conflicting with its documentation
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6
Status: closed Resolution: duplicate
Dependencies: Superseder: fstring's '{' from escape sequences does not start an expression
View: 28590
Assigned To: docs@python Nosy List: docs@python, eric.smith, fabioz
Priority: normal Keywords:

Created on 2016-11-03 13:30 by fabioz, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg279992 - (view) Author: Fabio Zadrozny (fabioz) * Date: 2016-11-03 13:30
The file:

/Doc/reference/lexical_analysis.rst says that things as:

f"abc {a[\"x\"]} def"  # workaround: escape the inner quotes
f"newline: {ord('\\n')}"  # workaround: double escaping
fr"newline: {ord('\n')}"  # workaround: raw outer string

are accepted in f-strings, yet, all those examples raise a:

SyntaxError: f-string expression part cannot include a backslash

The current Python version where this was tested is: 3.6.0b4

So, either those cases should be supported or lexical_analysis.rst should be updated to say that '\' is not valid in the expression part of f-strings.
msg279995 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-11-03 13:47
This is a duplicate of issue 28590.
Date User Action Args
2022-04-11 14:58:39adminsetgithub: 72783
2016-11-03 13:47:14eric.smithsetstatus: open -> closed
superseder: fstring's '{' from escape sequences does not start an expression
messages: + msg279995

resolution: duplicate
stage: resolved
2016-11-03 13:43:31serhiy.storchakasetversions: + Python 3.7
nosy: + docs@python, eric.smith

assignee: docs@python
components: + Documentation, - Interpreter Core
type: behavior
2016-11-03 13:30:54fabiozcreate