New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:
Compare printf-style string formatting and new-style string formatting. >>> '%-020d' % 42 '42 ' >>> format(42, '<020') '42000000000000000000' >>> format(42, '<020d') '42000000000000000000' >>> '%-020x' % 42 '2a ' >>> format(42, '<020x') '2a000000000000000000' >>> '%-020g' % 1.2e-8 '1.2e-08 ' >>> format(1.2e-8, '<020') '1.2e-080000000000000' >>> format(1.2e-8, '<020g') '1.2e-080000000000000' >>> format(1.2e-8, '<020e') '1.200000e-0800000000' New-style string formatting produces the result that looks like a correctly formatted number, but it represents incorrect number. I think that zero padding should not be allowed for left-aligned format for numbers (except the 'f' format). Zero padding is already disallowed for complex numbers. ---------- components: Interpreter Core messages: 332231 nosy: eric.smith, serhiy.storchaka priority: normal severity: normal status: open title: String formatting produces incorrect result with left-aligned zero-padded format _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35546> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com