tests/cpydiff: Clarify f-string diffs regarding concatenation.

Concatenation of any literals (including f-strings) should be avoided.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
pull/8031/head
Jim Mussared 2021-11-18 23:29:48 +11:00 zatwierdzone przez Damien George
rodzic 11ed94797d
commit e99f7b6d25
1 zmienionych plików z 8 dodań i 7 usunięć

Wyświetl plik

@ -1,12 +1,13 @@
""" """
categories: Core categories: Core
description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces or are f-strings
cause: MicroPython is optimised for code space. cause: MicroPython is optimised for code space.
workaround: Use the + operator between literal strings when either is an f-string workaround: Use the + operator between literal strings when either or both are f-strings
""" """
x = 1 x, y = 1, 2
print("aa" f"{x}") print("aa" f"{x}") # works
print(f"{x}" "ab") print(f"{x}" "ab") # works
print("a{}a" f"{x}") print("a{}a" f"{x}") # fails
print(f"{x}" "a{}b") print(f"{x}" "a{}b") # fails
print(f"{x}" f"{y}") # fails