[Python-3000] PEP 3101 update

Rudy Rudolph rudyrudolph at excite.com
Wed Jun 14 21:45:14 CEST 2006


Greg Ewing wrote:
>So what you're really asking for is an option for
>suppressing trailing zeroes after a decimal point
>(and replacing them with spaces).
>That makes sense, although I think calling it
>"decimal align" would be confusing. It confused
>me, because I was thinking of what this means in
>a word processor, where you're aligning decimal
>points with some predetermined absolute position.

Formatting with 'g' instead of 'f' already suppresses
trailing zeroes (and the decimal point if there is no
fractional part). Calling it "decimal align" is just as
valid as your "right align" and "left align". That is,
they align the current piece relative to what was printed
before; none gives you absolute positioning. However, if
a) the same format string is used for every line, b) all
fields specify a width, and c) nothing exceeds its format
width, then all the columns will align left, right, decimal,
or whatever. That's one of the main uses of format strings,
using relative positioning one line at a time to achieve a
poor-man's table with the fields in all lines aligned in
columns as if the positions had been specified absolutely.

Center- and decimal-align nicely round out the left-align,
right-align, and pad-after-sign formatting already proposed,
and are easy to implement. I therefore ask that they be added
to the PEP. BTW, I very much like the proposal in the PEP.

Issue to consider: Can decimal alignment be specified together
with pad-after-space?

Rudy

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!




More information about the Python-3000 mailing list