Skip to content

Instantly share code, notes, and snippets.

@SecurityForUs
Created September 25, 2012 23:56
Show Gist options
  • Save SecurityForUs/3785180 to your computer and use it in GitHub Desktop.
Save SecurityForUs/3785180 to your computer and use it in GitHub Desktop.
Workaround from using Math functions
def fmt_currency(val):
tmp = val
if not isinstance(tmp, str):
tmp = str(tmp)
if val < 100:
cents = tmp
dollars = "0"
else:
cents = tmp[-2:]
dollars = tmp[0:len(tmp)-2]
return "%s.%s" % (dollars, cents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment