Re: Insert comma in number?

2013-03-07 Thread John Posner
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")

Re: Insert comma in number?

2013-03-07 Thread Peter Otten
Paul Volkov wrote: > 2013/3/7 Peter Otten <__pete...@web.de>: >> Last not least there's the option to employ locale-aware formatting: >> > import locale > locale.setlocale(locale.LC_ALL, "en_US.UTF-8") >> 'en_US.UTF-8' > locale.format("%d", 12345, grouping=True) >> '12,345' >> >> In Ge

Re: Insert comma in number?

2013-03-07 Thread Paul Volkov
2013/3/7 Peter Otten <__pete...@web.de>: > Last not least there's the option to employ locale-aware formatting: > import locale locale.setlocale(locale.LC_ALL, "en_US.UTF-8") > 'en_US.UTF-8' locale.format("%d", 12345, grouping=True) > '12,345' > > In German usage of "." and "," is re

Re: Insert comma in number?

2013-03-06 Thread Peter Otten
eli m wrote: > I have a python program that accepts input and calculates the factorial of > that number, and i want to know if i can make it so commas get inserted in > the number. For example: instead of 1000 it would say 1,000 Last not least there's the option to employ locale-aware formatting:

Re: Insert comma in number?

2013-03-06 Thread Terry Reedy
On 3/6/2013 7:07 PM, Chris Rebert wrote: On Wed, Mar 6, 2013 at 3:39 PM, eli m wrote: I have a python program that accepts input and calculates the factorial of that number, and i want to know if i can make it so commas get inserted in the number. For example: instead of 1000 it would say 1,0

Re: Insert comma in number?

2013-03-06 Thread Chris Rebert
On Wed, Mar 6, 2013 at 3:39 PM, eli m wrote: > I have a python program that accepts input and calculates the factorial of > that number, and i want to know if i can make it so commas get inserted in > the number. > For example: instead of 1000 it would say 1,000 Use the "," (i.e. comma) format(

Re: Insert comma in number?

2013-03-06 Thread ian douglas
On 03/06/2013 03:39 PM, eli m wrote: I have a python program that accepts input and calculates the factorial of that number, and i want to know if i can make it so commas get inserted in the number. For example: instead of 1000 it would say 1,000 pip install humanize import humanize my_int

Insert comma in number?

2013-03-06 Thread eli m
I have a python program that accepts input and calculates the factorial of that number, and i want to know if i can make it so commas get inserted in the number. For example: instead of 1000 it would say 1,000 -- http://mail.python.org/mailman/listinfo/python-list