Rough draft: Proposed format specifier for a thousands separator

Raymond Hettinger python at rcn.com
Thu Mar 12 11:56:33 CET 2009


[Ulrich Eckhardt]
> IOW, why not explicitly say what you want using keyword arguments with
> defaults instead of inventing an IMHO cryptic, read-only mini-language?

That makes sense to me but I don't think that's the way the format()
builtin was implemented (see PEP 3101 which was implemented Py2.6 and
3.0).
It is a simple pass-through to a __format__ method for each
formattable
object.  I don't see how keywords would fit in that framework.  What
is
proposed is similar to locale module's existing "n" specifier except
that
this lets you say exactly what you want instead of deferring to the
locale
settings.

The mini-language seems to already be the way of things (just as it is
many other languages including PHP, C, Fortran, and whatnot).  I'm
just
proposing an addition "T," so you add commas as a thousands separator.


Raymond




More information about the Python-list mailing list