From: Alan G Isaac on
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?

Thanks,
Alan Isaac


From: MRAB on
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.
From: Alan G Isaac on
On 5/11/2010 3:19 PM, MRAB wrote:
> You usually want numbers to be right-aligned so that the decimal points
> line up when writing a columns of them.


Yes. I'm not questioning the wisdom of the implementation,
just the documentation of it.

Thanks,
Alan

From: Terry Reedy on
On 5/11/2010 3:19 PM, MRAB wrote:
> 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.

http://bugs.python.org/issue8691

From: Alan G Isaac on
On 5/11/2010 5:05 PM, Terry Reedy wrote:
> http://bugs.python.org/issue8691

Thanks!

Alan