On 29/06/2020 15:29, Mikhail V wrote:
Proposal:
Allow standard python escapes inside curly braces in f-strings. Main point is to make clear visual distinction between text and escaped chars:
# current syntax: print ("\nnewline") print ("\x0aa")
# new syntax: print (f"{\n}newline") print (f"{\x0a}a")
What goes inside curly braces inside an f-string is a Python *expression*:
print(f"{2+40}")
42
It would be totally inconsistent to allow an *unquoted* string instead (with or without escape characters). Did you mean to write
# new syntax: print (f"{'\n'}newline") print (f"{'\x0a'}a")
That in my opinion would make sense (I was surprised when I discovered it wasn't legal syntax) although personally I probably wouldn't use it to make a visual distinction as you describe. But apparently there are difficulties in implementing it.