documentation bug? (format spec mini language)

MRAB python at mrabarnett.plus.com
Tue May 11 15:19:53 EDT 2010


Alan G Isaac wrote:
> The documentation at 
> http://docs.python.org/py3k/library/string.html#format-specification-mini-language 
> 
> 
>         '<' Forces the field to be left-aligned within the available 
> space (This is the default.)
> 
> The conflicting example::
> 
>         >>> format(3.2,'10.5f')
>         '   3.20000'
>         >>> format(3.2,'<10.5f')
>         '3.20000   '
> 
> Am I somehow misreading the documentation?
> 
It does look misleading. Numbers default to right-aligned, as you
discovered.

You usually want numbers to be right-aligned so that the decimal points
line up when writing a columns of them.



More information about the Python-list mailing list