[issue38657] String format for hexadecimal notation breaks padding with alternative form

Pete Wicken report at bugs.python.org
Sat Nov 2 10:23:44 EDT 2019


Pete Wicken <petewicken at gmail.com> added the comment:

Given the comments above I appreciate that this is actually due to the padding being the total field width rather than the padding of the digits themselves. Having revised the documentation again, I believe this following line is explaining it:

"When no explicit alignment is given, preceding the width field by a zero ('0') character enables sign-aware zero-padding for numeric types. This is equivalent to a fill character of '0' with an alignment type of '='."

(https://docs.python.org/3.8/library/string.html)

I initially read "sign-aware zero-padding for numeric types" to mean the padding would not blindly prepend, and would take into account any signs and pad after (hence initially making this a bug). So maybe as suggested above we should explicitly mention the padding is the total number of characters in the field, rather than just the numbers.

I can look into adding this soon and see what you all think.

----------

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


More information about the Python-bugs-list mailing list