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


Groups > comp.lang.python > #45861

Re: PEP 378: Format Specifier for Thousands Separator

Newsgroups comp.lang.python
Date 2013-05-23 19:29 -0700
References <BLU176-W10190CB892A0414C988A05D7A80@phx.gbl>,> <nad-F52CE7.22440720052013@news.gmane.org>,> <CADUW+M=Y7b=4ZEENVzx4p6YpVD8T0eG=qz7sz8+iEow-5-o+jQ@mail.gmail.com> <mailman.1929.1369162176.3114.python-list@python.org>
Message-ID <b87bfa97-e0cc-489e-847b-02d9312060bd@googlegroups.com> (permalink)
Subject Re: PEP 378: Format Specifier for Thousands Separator
From 88888 Dihedral <dihedral88888@gmail.com>

Show all headers | View raw


Carlos Nepomuceno於 2013年5月22日星期三UTC+8上午2時49分28秒寫道:
> ________________________________
> > 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

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.




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


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