At some point in doing web application using web2py/Python I need to show numbers in money formatted string. Seems a little problem easy to handle, at first. After searching about money at Python Package Index then I know it was quite complex matter involved many things…
Anyway, the money format for my purpose it is enough to use simple function to convert number to money formatted string, and I use “moneyfmt” recipe I found at Python Docs, modified it a little, set places=0  as default, add condition if places == 0  to automatically set dp=''  if places=0, so I don’t have to set “dp” parameter when I need to change the number of “places”.

Then, for example, I put this function in models/db.py , don’t forget to import Decimal:

and we can use it application-wide, for example in views/default/showbill.html, like: