Message332231
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. |
|
Date |
User |
Action |
Args |
2018-12-20 14:41:00 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, eric.smith |
2018-12-20 14:41:00 | serhiy.storchaka | set | messageid: <1545316860.16.0.788709270274.issue35546@psf.upfronthosting.co.za> |
2018-12-20 14:41:00 | serhiy.storchaka | link | issue35546 messages |
2018-12-20 14:41:00 | serhiy.storchaka | create | |
|