[issue39077] Numeric formatting inconsistent between int, float and Decimal

Eric V. Smith report at bugs.python.org
Tue Dec 17 16:45:28 EST 2019


Eric V. Smith <eric at trueblade.com> added the comment:

I'm not sure what you mean by the "pre-width 0". Is that the "0" here:

format_spec ::=  [[fill]align][sign][#][0][width][grouping_option][.precision][type]

?

And now that I write out the question, I'm sure that's what you mean.

PEP 3101 says "If the width field is preceded by a zero ('0') character, this enables zero-padding. This is equivalent to an alignment type of '=' and a fill character of '0'.". I don't see any other discussion of it in the PEP. In particular, what if you specify a different alignment type with the pre-width 0?

I believe this all originated in C's printf, via PEP 3101. Has anyone checked what C does?

But in any event, I don't think we can change the int formatting, in particular. There's no doubt someone who's relying on every little quirk. I'm less concerned about float and decimal, although we'd still need to be very careful.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39077>
_______________________________________


More information about the Python-bugs-list mailing list