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


Groups > comp.lang.python > #45642 > unrolled thread

PEP 378: Format Specifier for Thousands Separator

Started byCarlos Nepomuceno <carlosnepomuceno@outlook.com>
First post2013-05-21 08:17 +0300
Last post2013-05-21 08:17 +0300
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#45642 — PEP 378: Format Specifier for Thousands Separator

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-21 08:17 +0300
SubjectPEP 378: Format Specifier for Thousands Separator
Message-ID<mailman.1902.1369113524.3114.python-list@python.org>
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? 		 	   		  

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web