cross platform use of set locale

Timothy Smith timothy at open-networks.net
Tue Mar 22 19:33:13 EST 2005


Marc 'BlackJack' Rintsch wrote:

>In <mailman.746.1111534956.1799.python-list at python.org>, Timothy Smith
>wrote:
>
>  
>
>>hi there i need to set my locale so that when i output a number it's 
>>formatted with thousands grouped. the problem i've found is there 
>>doesn't seem to be very good cross platform support for locales, even 
>>between unix's it's horrid.
>>    
>>
>
>Have you tried this::
>
>  import locale
>  locale
>  locale.setlocale(LC_ALL, '')
>  locale.format('%.2f', 1000000, True)
>
>The `True` turns on grouping.  Should work cross platform.
>
>Ciao,
>	Marc 'BlackJack' Rintsch
>  
>
thats ok, but how do i get it to group thousands with a , ?
and thats would mean i'd have to run everything through a formatter 
before i displayed it :/ it'd be nicer if i could just select a proper 
locale



More information about the Python-list mailing list