A suggestion for a possible Python module

Matt Gerrans mgerrans at mindspring.com
Sat Mar 8 22:00:55 EST 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