howto format currency string?

A

adegreiff

hi,

using zope/pythons/page templates i need to format a float number to a
string like 10,250.10

(note the thousand separator and the trailing zero in the decimal)

i was able to use %0.2f bit that returned no thousand separator.
i was able to use thousands_commas function but that returned
"10,250.1" which is wrong.

any ideas?

thanks
alexander
 
A

Alex Martelli

adegreiff said:
hi,

using zope/pythons/page templates i need to format a float number to a
string like 10,250.10

(note the thousand separator and the trailing zero in the decimal)

i was able to use %0.2f bit that returned no thousand separator.
i was able to use thousands_commas function but that returned
"10,250.1" which is wrong.

any ideas?


Alex
 
P

Peter Otten

Alex said:
'en_US.ISO8859-1'


Python 2.3 (#1, Jul 30 2003, 11:19:43)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.'de_DE.ISO8859-1'

It works :)
And I always trusted the documentation/error message:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "locale.py", line 381, in setlocale
return _setlocale(category, locale)
locale.Error: locale setting not supported
The second (not working) variant is taken directly from the documentation.
The error message led me to assume that my version of Python didn't support
locale setting at all.

Maybe I should file a bug report?

Peter
 
A

Alex Martelli

Peter Otten wrote:
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "locale.py", line 381, in setlocale
return _setlocale(category, locale)
locale.Error: locale setting not supported

The second (not working) variant is taken directly from the documentation.
The error message led me to assume that my version of Python didn't
support locale setting at all.

Maybe I should file a bug report?

Yes, I believe that the error message is potentially misleading, and
filing a bug report is a good way to have it fixed ASAP, thanks.


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top