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")
Currently it is SyntaxError:
"SyntaxError: f-string expression part cannot include a backslash"
Further, I suggest hex code escapes with a new prefix "\ ", i.e.
backslash+space,
(this would work in f-strings only obviously) so it could be used
instead current
variants: \\x, \\u, and \\U without need to include all leading zeros in codes.
Consecutive codes can be simply separated by space.
Example:
# current syntax:
print ("\x48\x65\x6c\x6c\x6f\U0001F601") # Hello and a smiley
print ("\x0aa")
# new syntax:
print (f"{\ 48 65 6c 6c 6f 01F601}")
print (f"{\ 0a}a")
And I personally would like to see an option for decimal charcodes,
e.g. with "\." prefix using the same schema as above with hex codes.
Mikhail