In <[EMAIL PROTECTED]>, abcd wrote:

> if i have a number, say the size of a file, is there an easy way to
> output it so that it includes commas?
> 
> for example:
> 
> 1890284
> 
> would be:
> 
> 1,890,284

I think this comes close:

In [23]: import locale

In [24]: locale.setlocale(locale.LC_ALL, '')
Out[24]: 'en_US.UTF-8'

In [25]: locale.format('%d', 1890284, True)
Out[25]: '1,890,284'

It's not always commas but whatever character is used to group thousands
in the active locale.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to