Code in question:
a = 'test'
print(f'{a}')
print(f'{ {a} }')
print(f'{{ {a} }}')
My question is why do two cases print these quotes?
I did not find anything explicitly in the documentation. The closest I found is described in detail in PEP for this function:
(grammar for F-lines)
f ' <text> { <expression> <optional !s, !r, or !a> <optional : format specifier> } <text> ... '
The expression is then formatted using the format protocol , using the format specifier as an argument. The resulting value is used when building the value of the f-string.
I believe the value is aformatted using some formatting, which, since the data type is a string, wraps it in quotation marks. This result then returns to the surrounding F-string formatting instance.
? - , ?