Documentation
On this page: https://docs.python.org/3.14/library/string.html#grammar-token-format-spec-format_spec
format_spec: [options][width_and_precision][type]
options: [[fill]align][sign]["z"]["#"]["0"]
fill: <anycharacter>align: "<"|">"|"="|"^"sign: "+"|"-"|" "width_and_precision: [width_with_grouping][precision_with_grouping]
width_with_grouping: [width][grouping]
precision_with_grouping: "." [precision][grouping]
width: digit+precision: digit+grouping: ","|"_"type: "b"|"c"|"d"|"e"|"E"|"f"|"F"|"g"|"G"|"n"|"o"|"s"|"x"|"X"|"%"
The precision_with_grouping syntaxe is wrong, because it accepts . without precision or grouping. But
>>>f'{1234.1234:.f}'Traceback (mostrecentcalllast):
File"<python-input-17>", line1, in<module>f'{1234.1234:.f}'^^^^^^^^^^^^^^ValueError: Formatspecifiermissingprecision(The error does not mention grouping either)
The right syntax should be
precision_with_grouping: "."precision [grouping] |"."grouping
Linked PRs
Documentation
On this page: https://docs.python.org/3.14/library/string.html#grammar-token-format-spec-format_spec
The
precision_with_groupingsyntaxe is wrong, because it accepts.withoutprecisionorgrouping. But(The error does not mention grouping either)
The right syntax should be
Linked PRs
precision_with_groupingin format description #134608precision_with_groupingin format description (GH-134608) #135015