PEP 378: Format Specifier for Thousands Separator
88888 Dihedral
dihedral88888 at gmail.com
Thu May 23 22:29:14 EDT 2013
Carlos Nepomuceno於 2013年5月22日星期三UTC+8上午2時49分28秒寫道:
> ________________________________
> > From: alyssonbruno at gmail.com
> > Date: Tue, 21 May 2013 09:03:13 -0300
> > Subject: Re: PEP 378: Format Specifier for Thousands Separator
> > To: python-list at 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
Could a separate instance like the I/O device of a subprocess
to be easily available in Python?
The next question would be whether the flow of several I/O data streams could be easily piped and manipulated in the high level
programming designs without consuming too much resources.
More information about the Python-list
mailing list