Rough draft: Proposed format specifier for a thousands separator

Lie Ryan lie.1296 at
Fri Mar 13 07:04:50 CET 2009

Hendrik van Rooyen wrote:
> "Ulrich Eckhardt" <> wrote:
>> IOW, why not explicitly say what you want using keyword arguments with
>> defaults instead of inventing an IMHO cryptic, read-only mini-language?
>> Seriously, the problem I see with this proposal is that its aim to be as
>> short as possible actually makes the resulting format specifications
>> unreadable. Could you even guess what "8T.,1f" should mean if you had not
>> written this?
> +1
> Look back in history, and see how COBOL did it with the
> PICTURE - dead easy and easily understandable.
> Compared to that, even the C printf stuff  and python's %
> are incomprehensible.
> - Hendrik

Seeing how many people complained for the proposal being unreadable 
(although it tries to be simple by not including too much features), why 
not go all the way to unreadability and teach people to always use some 
sort of convenience function and never use the microlanguage except of 
very simple cases (or extremely complex cases, in which case you might 
actually be better served with writing your own formatting function).

A hyphotetical code using conv function and the microlanguage could look 
like this:

 >>> num = 213210.3242
 >>> fmt = create_format(sep='-', decsep='@')
 >>> print fmt
 >>> '{0!{1}}'.format(num, fmt)
'213-210 at 3242'

More information about the Python-list mailing list