← index #3223Issue #7946
Off-topic · high · value 0.963
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

Syntax error on F-String?

closedby will-caopened 2021-10-27updated 2021-11-01

No idea what's happening.

Feels simple enough that I'm probably doing something obvious wrong, but also simple enough that I can't see what:

MicroPython 4fe0332-dirty on 2021-10-27; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> f"{5}"
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: invalid syntax
>>> print(f"{5}")
Traceback (most recent call last):
  File "<stdin>", line 1
SyntaxError: invalid syntax
>>> import sys
>>> sys.implementation
(name='micropython', version=(1, 16, 0), mpy=2821)

Don't see anything to explain this in the list of known differences.

I suppose F-Strings are a 3.6 feature, but I assume they're included under the "selected features from later versions"?

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