Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45680
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
|---|---|
| Subject | RE: PEP 378: Format Specifier for Thousands Separator |
| Date | 2013-05-21 21:49 +0300 |
| References | <CADUW+M=Y7b=4ZEENVzx4p6YpVD8T0eG=qz7sz8+iEow-5-o+jQ@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1929.1369162176.3114.python-list@python.org> (permalink) |
________________________________
> From: alyssonbruno@gmail.com
> Date: Tue, 21 May 2013 09:03:13 -0300
> Subject: Re: PEP 378: Format Specifier for Thousands Separator
> To: python-list@python.org
>
> This work in 3.1+:
>
> $ python3
> Python 3.1.3 (r313:86834, Nov 28 2010, 11:28:10)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> one_number = 1234567
> >>> print('number={:,}'.format(one_number))
> number=1,234,567
> >>>
>
Thank you, but let me rephrase it. I'm already using str.format() but I'd like to use '%' (BINARY_MODULO) operator instead.
I've looked into the source code of CPython 2.7.5 and I've found no evidence of the thousands separator been implemented on formatint() in "Objects/unicodeobject.c".
I also didn't find the _PyString_FormatLong() used in formatlong(). Where is _PyString_FormatLong() located?
So, the question is: Where would I change the CPython 2.7.5 source code to enable '%' (BINARY_MODULO) to format using the thousands separator like str.format() does, such as:
>>>sys.stderr.write('%,d\n' % 1234567)
1,234,567
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-21 21:49 +0300
Re: PEP 378: Format Specifier for Thousands Separator 88888 Dihedral <dihedral88888@gmail.com> - 2013-05-23 19:29 -0700
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-24 18:25 +0300
Re: PEP 378: Format Specifier for Thousands Separator Andreas Perstinger <andipersti@gmail.com> - 2013-05-24 19:28 +0200
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-25 00:07 +0300
csiph-web