Rough draft: Proposed format specifier for a thousands separator

Paul Rubin http
Thu Mar 12 14:01:39 EDT 2009


Raymond Hettinger <python at rcn.com> writes:
> In my quick research, it looks like many languages offer
> nothing more than the usual C style % formatting and defer
> the rest for a local aware module.

Hendrik van Rooyen's mention of Cobol's "picture" (aka PIC)
specifications might be added to the list.  Cautionary tale: I once
had a similar idea and suggested including a bastardized version of
PIC in an extension language for something I worked on once.  Another
programmer then coded a reasonable PIC subset and we shipped it.
Turned out that a number of our users were Cobol experts and once we
had anything like PIC, they expected the weirdest and most obscure
features (of which there were quite a few) of real Cobol PIC to work.
We ended up having to assign someone a fairly lengthy task of figuring
out the Cobol spec and implementing every last damn PIC feature.  But
I digress.


> > example, I think Common Lisp has a feature for formatting thousands.
> Do you have more detail?

 http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node200.html

gives as an example:

 (format nil "The answer is ~:D." (expt 47 x)) 
                                => "The answer is 229,345,007."




More information about the Python-list mailing list