Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45642

PEP 378: Format Specifier for Thousands Separator

From Carlos Nepomuceno <carlosnepomuceno@outlook.com>
Subject PEP 378: Format Specifier for Thousands Separator
Date 2013-05-21 08:17 +0300
Newsgroups comp.lang.python
Message-ID <mailman.1902.1369113524.3114.python-list@python.org> (permalink)

Show all headers | View raw


Is there a way to format integers with thousands separator (digit grouping) like the format specifier of str.format()?

I'm currently using the following:

>>> sys.stdout.write('Number = %s\n' % '{:,.0f}'.format(x))
Number = 12,345

'x' is unsigned integer so it's like using a sledgehammer to crack a nut!

I'd like to have something like:

sys.stdout.write('Number = %,u\n' % x)


Is that possible? How can I do it if not already available? 		 	   		  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-21 08:17 +0300

csiph-web