Skip to content

Instantly share code, notes, and snippets.

@victorono
Last active June 16, 2016 02:35
Show Gist options
  • Save victorono/ef1d4764efa575a466673d8690c87667 to your computer and use it in GitHub Desktop.
Save victorono/ef1d4764efa575a466673d8690c87667 to your computer and use it in GitHub Desktop.
format currency
def format_currency(value, decimal_points=3, seperator=u'.', money=u'$'):
value = str(value)
if len(value) <= decimal_points:
return value
parts = []
while value:
parts.append(value[-decimal_points:])
value = value[:-decimal_points]
parts.reverse()
value = "%s %s" % (money, seperator.join(parts))
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment