summaryrefslogtreecommitdiffstatshomepage
path: root/tests/cpydiff/core_fstring_concat.py
blob: 2fbe1b961a1e61d4ea8637ae9fe3b0432391239c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""
categories: Core,f-strings
description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces
cause: MicroPython is optimised for code space.
workaround: Use the + operator between literal strings when they are not both f-strings
"""

x, y = 1, 2
# fmt: off
print("aa" f"{x}")  # works
print(f"{x}" "ab")  # works
print("a{}a" f"{x}")  # fails
print(f"{x}" "a{}b")  # fails
# fmt: on