Shouldn't %06s zero-pad a string?

Beat Bolli b11 at gmx.Dont-Spam.net
Thu Feb 13 17:09:02 EST 2003


Jeff Epler wrote:
> Python generally takes inspiration for the handling of %-formats from
> the C standard.
> 
> [Tests snipped]
> 
> Here's what my printf manual page says about '0':
> 
>        0      The value should be zero padded.  For d, i,  o,  u,
>               x,  X,  a, A, e, E, f, F, g, and G conversions, the
>               converted value is padded on the  left  with  zeros
>               rather  than  blanks.   If  the  0 and - flags both
>               appear, the 0 flag is ignored.  If a  precision  is
>               given with a numeric conversion (d, i, o, u, x, and
>               X), the 0 flag is ignored.  For other  conversions,
>               the behavior is undefined.
> 
> so "the behavior is undefined" when the s conversion is used.
> The treatment of 0 as " " (space) seems fairly useful, though.
> 
That's all fine, but the *Python* manual mentions no such limitation. 
Wouldn't be simpler to handle all cases consistently?

Still-wondering-whether-to-file-a-bug-ly yours

Beat Bolli





More information about the Python-list mailing list