Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45642 > unrolled thread
| Started by | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
|---|---|
| First post | 2013-05-21 08:17 +0300 |
| Last post | 2013-05-21 08:17 +0300 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-21 08:17 +0300
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
|---|---|
| Date | 2013-05-21 08:17 +0300 |
| Subject | PEP 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?
Back to top | Article view | comp.lang.python
csiph-web