cross platform use of set locale

Timothy Smith timothy at open-networks.net
Wed Mar 23 05:52:06 EST 2005


Serge Orlov wrote:

>Timothy Smith wrote:
>  
>
>>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
>>    
>>
>
>I think you're misusing locale. There is no guarantee that any specific
>locale will have properties (like grouping) set to a known value.
>Are you trying to format money? Then you need a special class so that
>you can say:
>
>d = Dollars(1000000.01)
>print "You have %s in your account" % d
>
>and get
>
>You have $1,000,000.01 in your account.
>
>  Serge.
>
>  
>
thats exactly what i'm trying to do, only having to do that for all my 
outputs is more work then i'd like :/
why is this a misuse of locale? it's exactly what locale is meant for 
isn't it?



More information about the Python-list mailing list