[Python-3000] PEP 3101 update
rudyrudolph at excite.com
Tue Jun 13 19:33:30 CEST 2006
Rudy Rudolph wrote:
>It would be nice to have align centered and align on decimal point.
>However, with 'g' formatting the number of digits after the point may
>vary and there may not even be a decimal point. In this case, a column
>of numbers should be aligned at the last digit of the integer part.
Greg Ewing wrote:
>How do you do that when you're formatting one string at a time?
I thought the whole idea of alignment specifications was so that we could print one line at a time but get everything to line up.
To right align, we use '>' for align and specify the last position
relative to the what came before. That relative position is known
as the field width.
To decimal align, we use a different char for align and specify the
decimal position relative to what came before. One possible way
to do this is with, for example, '9.3g' which means fill chars and
digits in the first 5 positions, a decimal point if necessary in the
sixth position, and digits and fill chars in the last three positions.
If the same format string is used for every line printed, the decimals
line up, just like the right sides line up with right alignment. Well,
actually the last digits of the integer portions line up even if there
isn't a decimal point, just like with a decimal tab in MS Word.
There are certainly other ways to specify the same thing and I don't
much care what the format is. It should be easy enough both to settle
on a format and to implement, and it would certainly be useful.
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
More information about the Python-3000