[Zope] Re: Formatting numbers with commas in Python Script or ZPT

Evan Simpson evan@4-am.com
Wed, 19 Feb 2003 18:33:29 -0600


Michael LaPera wrote:
> I thought this would be easy, but I can seem to figure out how to format 
> a number with commas (US currency).

In a Script:

   from Products.PythonScripts.standard import thousands_commas
   s = thousands_commas(123456.78)

In a ZPT:

   <div tal:define="pss modules/Products/PythonScripts/standard"
        tal:replace="python:pss.thousands_commas(123456.78)">
   123,456.78
   </div>

Cheers,

Evan @ 4-am