-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Parse Valid Cpython syntax when concatenating f-strings #5938
Comments
It's worth noting that this limitation also exists in micropython, see MicroPython v1.18-56-g517e82eb6-dirty on 2022-01-28; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> f"" f""
Traceback (most recent call last):
File "<stdin>", line 1
SyntaxError: invalid syntax Using "+" instead of f-string literal concatenation is the official recommendation. If a future version of Micropython improves in this area, we'll get the improvement by merging that future release into CircuitPython. We should make sure that this language difference is mentioned in our docs, as it is in theirs. |
Thanks, I had not searched the micropython side. I have been using this feather with Rust (RTIC) and Tinygo as circuitpython was not quite there when I first tried it. In the mean time, With async/await now on the scene, I am all in and look forward to helping where I can. |
Awesome! You may want to join #circuitpython-dev on the Discord chat as well: https://adafru.it/discord That's where we discuss CP dev work. |
It looks like the very useful "core language" page from micropython is not in the circuitpython docs: https://docs.micropython.org/en/latest/genrst/core_language.html most of these items apply to circuitpython as well. |
CircuitPython version
Code/REPL
Behavior
The parser does not properly concatenate two f-strings as used when splitting across lines.
One regular string and one f-string works correctly,
One g-string and one regular string works correctly
Two regular strings work correctly.
Two f-stings, "invalid syntax"
Using the "+" operator on two f-stings works, but it allocates a transient sting on the fly which then needs to be garbage collected
Cpython accepts two f-srings
Description
Gets flagged at compile time as an error and code does not run.
REPL has same issue.
Additional information
Here is the REPL session in cpython on Arch Linux working as expected
The text was updated successfully, but these errors were encountered: