Closed
Description
Feature
Toy Example (adapted from extra_tests/snippets/fstrings.py
, lines 47-48)
Code
foo = "bar"
part_spec = ">+#10x"
print(f"{16:0{part_spec}}{foo}")
CPython
00000+0x10bar
RustPython
SyntaxError: Got error in f-string: Invalid expression: invalid syntax. Got unexpected token 'part_spec' at line 1 column 9
print(f"{16:0{part_spec}}{foo}")
^
Real-world Example (adapted from CPython 3.9's Lib/test/test_fstring.py
, lines 581-584)
Code
import decimal
width = 10
precision = 4
value = decimal.Decimal('12.34567')
print(f'result: {value:{width}.{precision}}')
CPython
result: 12.35
RustPython
SyntaxError: Got error in f-string: Invalid expression: invalid syntax. Got unexpected token '{' at line 1 column 9
print(f'result: {value:{width}.{precision}}')
^
Python Documentation
https://docs.python.org/3/reference/lexical_analysis.html#grammar-token-python-grammar-format_spec
@coolreader18 this has been plaguing the CI for the past day or so (because of the --install-pip
step).
Metadata
Metadata
Assignees
Labels
No labels