A suggestion for a possible Python module

Matt Gerrans mgerrans at mindspring.com
Sun Mar 9 04:00:55 CET 2003


"Andrew Dalke" wrote:
> ...
> The ones I could think of are:
>   - insert commas in a number, as in "10000" -> "10,000"
>
>   def commafy(s):
>     s = s.reverse()
>     terms = []
>     for i in range(0, len(s), 3):
>       terms.append(s[i:i+3])
>     return ",".join(terms).reverse()
> ...

For this one, I'd prefer locale.format().







More information about the Python-list mailing list