Code: Select all
x = 1
y = 2
a = (
f"{x}"
f"{y}"
)
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 4
SyntaxError: invalid syntax
Any suggestions?
Should I raise an issue in Github?
thanks,
Chris
Code: Select all
x = 1
y = 2
a = (
f"{x}"
f"{y}"
)
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 4
SyntaxError: invalid syntax
Code: Select all
a = "".join([
f"{x}",
f"{y}"
])
Code: Select all
MicroPython v1.17 on 2021-09-02; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== x = 1
=== y = 2
=== a = (
=== f"{x}",
=== f"{y}"
=== )
===
>>> a
('1', '2')
>>>
Code: Select all
f"{x}" f"{y}"
Code: Select all
x = 1
y = 2
a = (
f"{x}",
f"{y}"
)
Code: Select all
x = 1
y = 2
a = f"{x}" f"{y}"
Code: Select all
a = f"{x}" + f"{y}"
Code: Select all
a = "".join((f"{x}", f"{y}"))
Code: Select all
c = f"""{a}\
{b}"""
I'm curious as to whether this came from library code or something you wrote -- obviously we'd love to make this scenario work, but it would come at a code size complexity. I'm glad in this case you got SyntaxError, but there are cases where it does the wrong thing. Any feedback about "real world" Python code is useful to guide how we might deal with the trade-offs here.
Code: Select all
def timestamp():
"""Get current timezone date/time from RTC as DD-MM-YYYY HH24:MM:SS."""
dt = datetime()
return '%02d-%02d-%d %02d:%02d:%02d' % \
(dt.day, dt.month, dt.year, dt.hour, dt.minute, dt.second)