Prev: Slice last char from string without raising exception on empty string (Re: Extract all words that begin with x)
Next: How to make this doctest work?
From: Alan G Isaac on 11 May 2010 14:33 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 11 May 2010 15:19 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 11 May 2010 16:23 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 11 May 2010 17:05 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 12 May 2010 21:51
On 5/11/2010 5:05 PM, Terry Reedy wrote: > http://bugs.python.org/issue8691 Thanks! Alan |