Formatting question : printing numbers with thousands separators ?

Fred Pacquier fredp at mygale.org.nospam
Fri Aug 31 10:44:20 EDT 2001


"Emile van Sebille" <emile at fenx.com> said :

> use locale:
>>>> import locale
>>>> locale.setlocale(locale.LC_ALL,"") 'English_United States.1252'
>>>> print locale.format('%.3f',12345.6789,1) 
> 12,345.679

Aha ! probably wouldn't have thought of nosing through _that_ module :)
Thanks for the tip - works great ! (even in French :)
 
> But watch out for negative numbers:
>>>> print locale.format('%.3f',-345.6789,1)
> -,345.679

For now these are file sizes -- normally not a problem :)
 
> HTH,

Certainly did ! Thanks again...

-- 
YAFAP : http://www.multimania.com/fredp/



More information about the Python-list mailing list