Is the following syntax unsupported f-lines in Python 3.6? If the string I appends to my f-string, the replacement does not happen:
SUB_MSG = "This is the original message."
MAIN_MSG = f"This longer message is intended to contain " \
"the sub-message here: {SUB_MSG}"
print(MAIN_MSG)
returns:
This longer message is intended to contain the sub-message here: {SUB_MSG}
If I remove the join line:
SUB_MSG = "This is the original message."
MAIN_MSG = f"This longer message is intended to contain the sub-message here: {SUB_MSG}"
print(MAIN_MSG)
works as expected:
This longer message is intended to contain the sub-message here: This is the original message.
In PEP 498 , the backslash inside the f-string is clearly not supported:
Time sequences
Backslashes may not appear inside parts of an f-string expression, so you cannot use them, for example, to avoid quotes inside f-lines:
>>> f'{\'quoted string\'}'
Are linear joins considered "inside the f-string expression part" and thus are not supported?
source
share