Couldn’t resist…
def bart(foo):
f"""{(
foo := foo + 1,
print('Finally, curly brackets in Python ;-)'),
[
print('Teacher: You should not use full Python in f-strings.')
for i in range(foo)
],
print(f'But you can... {foo}-)')
)}"""
bart(7)
…
Finally, curly brackets in Python ;-)
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
Teacher: You should not use full Python in f-strings.
But you can... 8-)
This is already possible in 3.10, but I strongly doubt that it was ever intended. Should we really head on in the same direction even more ?
Just to be clear: I like the PEP and support it, since it simplifies the implementation and removes some annoying bits (e.g. the backslash limitation), but I don’t like the removal of the string literal quoting rules and support for arbitrary nesting of f-strings. By keeping the quote restriction, arbitrary nesting can be prevented.