diff --git a/pep-0701.rst b/pep-0701.rst index 3661e6a2f..26009ce79 100644 --- a/pep-0701.rst +++ b/pep-0701.rst @@ -403,6 +403,13 @@ Here are some of the arguments in favour: def py2c(source): return f"{source.removesuffix(".py")}.c" +* Code generators (like `ast.unparse `_ from standard library) in their + current form rely on complicated algorithms to ensure expressions within an f-string are properly suited for the context in + which they are being used. These non-trivial algorithms come with challanges such as finding an unused quote type (by tracking + the outer quotes), and generating string representations which would not include backslashes if possible. Allowing quote reuse + and backslashes would simplify the code generators which deals with f-strings considerably, as the regular Python expression logic + can be used inside and outside of f-strings without any special treatment. + * Limiting quote reuse will considerably increase the complexity of the implementation of the proposed changes. This is because it will force the parser to have the context that is parsing an expression part of an f-string with a given quote in order to know if it needs to reject an expression that reuses the quote. Carrying this context around is not trivial in parsers that