By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

How to format a number?

P: n/a
I want to format a number with thousands separator to the 'pt_br'
locale.

I'm trying like this:
>>import locale
locale.setlocale(locale.LC_ALL, ('pt_br', 'ascii'))
'pt_BR.ISO8859-1'
>>locale.format('%d', 9876, True)
'9876'
>>locale.localeconv()['thousands_sep']
''
>>locale.localeconv()['mon_thousands_sep']
'.'

The thousands separator is defined only for the ['mon_thousands_sep']
key and not for the ['thousands_sep'] one. What should be done? Set the
['thousands_sep'] to '.' or somehow build the format string as a
monetary number? If any of the former, how?

Regards, Clodoaldo Pinto Neto

Jan 2 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.