Description
The form of format specifier is the following
[[fill]align][sign]["z"]["#"]["0"][width][grouping_option]["." precision][type]
Docs describe each option in the following order:
align
andfill
.sign
.- Option
z
. - Option
#
. - Option
,
. - Option
_
. width
, then option0
.precision
.type
.
As you can notice, options ,
and _
are not present in format spec, because they are actually part of grouping_option
. For whatever reason they are described before width
, but most importantly, their descriptions never mention they are part of grouping_option
.
It can be super confusing for the first readthrough, as descriptions are out of order and written similar to standalone options z
and #
. I suggest the following changes:
- Place descriptions of options
,
and_
after the description of width. - Mention that they are part of
grouping_option
. - Maybe change BNF specification of
grouping_option
to"," | "_"
to match their description order and order of addition to Python.
Example change:
The grouping_option determines how digits in numbers are grouped. Its first option,
','
, signals...The other grouping_option,
'_'
, signals...
Alternatively, these description can be placed in a table, similar for the list of string presentation types.
The grouping_option determines how digits in numbers are grouped. It can be one of the following:
==here goes the table==
Linked PRs
- gh-131912: Refactored description of grouping options in format specification docs #132030
- [3.13] gh-131912: Refactor description of grouping options in format specification docs (GH-132030) #132123
- [3.12] gh-131912: Refactor description of grouping options in format specification docs (GH-132030) #132203
- gh-131912: Use different grouping options for the integral and fractional parts #132170
Metadata
Metadata
Assignees
Projects
Status