Peter Otten wrote:

> Last not least there's the option to employ locale-aware formatting:


Not quite last ... there's the mind-bending regular expression route:

   import re
   re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "12345678")   # 12,345,678
   re.sub(r"(?<=\d)(?=(\d\d\d)+$)", ",", "-54321")     # -54,321

-John



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to