forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py/lexer: Support concatenation of adjacent f-strings.
This is quite a simple and small change to support concatenation of adjacent f-strings, and improve compatibility with CPython. Signed-off-by: Damien George <[email protected]>
- Loading branch information
Showing
3 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
""" | ||
categories: Core | ||
description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces or are 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 either or both are f-strings | ||
workaround: Use the + operator between literal strings when they are not both f-strings | ||
""" | ||
|
||
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 |