diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2021-11-18 23:29:48 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-11-25 22:09:59 +1100 |
commit | e99f7b6d25464f36accc2f04899edfa9e982bee2 (patch) | |
tree | 951545f8925c1cb125c54c7e65f84e470800825f | |
parent | 11ed94797d492cabdaf09396feb69a690e86f739 (diff) | |
download | micropython-e99f7b6d25464f36accc2f04899edfa9e982bee2.tar.gz micropython-e99f7b6d25464f36accc2f04899edfa9e982bee2.zip |
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>
-rw-r--r-- | tests/cpydiff/core_fstring_concat.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/cpydiff/core_fstring_concat.py b/tests/cpydiff/core_fstring_concat.py index fd83527b5c..c2bdb4e666 100644 --- a/tests/cpydiff/core_fstring_concat.py +++ b/tests/cpydiff/core_fstring_concat.py @@ -1,12 +1,13 @@ """ 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. -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 -print("aa" f"{x}") -print(f"{x}" "ab") -print("a{}a" f"{x}") -print(f"{x}" "a{}b") +x, y = 1, 2 +print("aa" f"{x}") # works +print(f"{x}" "ab") # works +print("a{}a" f"{x}") # fails +print(f"{x}" "a{}b") # fails +print(f"{x}" f"{y}") # fails |