← index #3223Issue #7786
Off-topic · high · value 1.108
QUERY · ISSUE

Unix: initialisation of multi-line dict can report wrong line number for syntax error.

openby peterhinchopened 2017-07-19updated 2024-08-28

The following:

a = {
    'one' : 1,
    'two' : 2,
    'three' : 3,
    'four', 4  # error
    }

produces the following outcome:

MicroPython v1.8.7-893-g46b849a on 2017-06-22; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import rats35
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rats35.py", line 2, in <module>
SyntaxError: expecting key:value for dict
>>> 
CANDIDATE · ISSUE

Concatenation of f-strings throws syntax error

closedby peterhinchopened 2021-09-14updated 2021-09-14

From this forum thread - ignore incorrect title:

x = 1
y = 2
f"{x}" f"{y}"

On CPython this produces 12. On MicroPython Unix build:

MicroPython v1.17 on 2021-09-02; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> x = 1
>>> y = 2
>>> f"{x}" f"{y}"
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: invalid syntax
>>> 

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied