[Python-Dev] string formatting options and removing basestring.__mod__ (WAS: Replacement for print in Python 3.0)

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Sep 7 05:47:10 CEST 2005


Bill Janssen wrote:
 >
 > someone wrote:
 >
> > Some languages have "picture" formats, where the structure
> > of the format string more closely mimics that of the desired
> > output.
>
> COBOL!  From the snippet Steven posted about C#, it seems to have a
> mode of "custom number formatting" which is picture-based.

A nice characteristic of a well-designed picture formatting
system is that the pictures take up the same amount of space
in the format string as the output they generate. So you
can write things like

   headings = "Description       Qty       Price         Amount"
   format   = "AAAAAAAAAAAAAAA  ###0   $#,##0.00  $#,###,##0.00"

and visually check that the headings and columns will line
up, without having to be concerned with the exact numbers of
characters in each column.

I think a picture-formatting function would be a nice thing
to have as an alternative to %-formatting or whatever will
replace it.

And-then-we-can-call-it-PyBol-3000-ly,

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list