RE: PEP 378: Format Specifier for Thousands Separator

Discussion in 'Python' started by Carlos Nepomuceno, May 21, 2013.

  1. ________________________________
    > From:
    > Date: Tue, 21 May 2013 09:03:13 -0300
    > Subject: Re: PEP 378: Format Specifier for Thousands Separator
    > To:
    >
    > 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'dlike 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
    Carlos Nepomuceno, May 21, 2013
    #1
    1. Advertising

  2. Carlos Nepomucenoæ–¼ 2013å¹´5月22日星期三UTC+8上åˆ2時49分28秒寫é“:
    > ________________________________
    > > From:
    > > Date: Tue, 21 May 2013 09:03:13 -0300
    > > Subject: Re: PEP 378: Format Specifier for Thousands Separator
    > > To:
    > >
    > > 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'dlike 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(). Whereis _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.
    88888 Dihedral, May 24, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlos Nepomuceno
    Replies:
    0
    Views:
    96
    Carlos Nepomuceno
    May 21, 2013
  2. Ned Deily
    Replies:
    0
    Views:
    86
    Ned Deily
    May 21, 2013
  3. Chris “Kwpolska†Warrick

    Re: PEP 378: Format Specifier for Thousands Separator

    Chris “Kwpolska†Warrick, May 21, 2013, in forum: Python
    Replies:
    0
    Views:
    85
    Chris “Kwpolska†Warrick
    May 21, 2013
  4. Skip Montanaro
    Replies:
    0
    Views:
    95
    Skip Montanaro
    May 21, 2013
  5. Mark Lawrence
    Replies:
    0
    Views:
    83
    Mark Lawrence
    May 21, 2013
Loading...

Share This Page