Steven D'Aprano added the comment:
Just change the f string quotes.
Python strings, whether f-strings or not, can be delimited by '' or "" or
triple quotes. So this works:
>>> f"But, {'this quote is right.'}"
'But, this quote is right.'
Remember that the part of the f-string is evaluated a
Eric V. Smith added the comment:
This is a limitation of the parser: the entire f-string is first evaluated as a
string.
Just as
'Hey, {' this quote is wrong.'}'
or
r'Hey, {' this quote is wrong.'}'
are not valid strings, neither is
f'Hey, {' this quote is wrong.'}'
See issue 33754 for a po
New submission from Nghia Minh :
I want to use the same type of quotation mark in f-string, like this:
f'Hey, {' this quote is wrong.'}'
Currently we have to:
f'But, {" this quote is right."}'
--
components: Library (Lib)
messages: 373296
nosy: Nghia Minh
priority: normal
severity: n