Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # TRADE_GOLD_WITH_THOUSANDS_SEPARATORS BEGIN
- def intWithCommas(x, commasign='.'):
- # alternative of
- # return '{0:,}'.format(x).replace(',', commasign)
- if type(x) not in [type(0), type(0L)]:
- raise TypeError("Parameter must be an integer.")
- if x < 0:
- return '-' + intWithCommas(-x, commasign)
- result = ''
- while x >= 1000:
- x, r = divmod(x, 1000)
- result = "%s%03d%s" % (commasign, r, result)
- return "%d%s" % (x, result)
- # TRADE_GOLD_WITH_THOUSANDS_SEPARATORS END
Add Comment
Please, Sign In to add comment