This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients eric.smith, serhiy.storchaka
Date 2018-12-20.14:41:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545316860.16.0.788709270274.issue35546@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-12-20 14:41:00serhiy.storchakasetrecipients: + serhiy.storchaka, eric.smith
2018-12-20 14:41:00serhiy.storchakasetmessageid: <1545316860.16.0.788709270274.issue35546@psf.upfronthosting.co.za>
2018-12-20 14:41:00serhiy.storchakalinkissue35546 messages
2018-12-20 14:41:00serhiy.storchakacreate