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


Groups > comp.lang.python > #45664

Re: PEP 378: Format Specifier for Thousands Separator

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <alyssonbruno@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.042
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; '21,': 0.07; 'brasil': 0.07; 'python3': 0.07; 'subject:PEP': 0.07; 'integers': 0.09; 'python': 0.11; '3.1.3': 0.16; 'alguns': 0.16; 'possible?': 0.16; 'specifier': 0.16; 'unsigned': 0.16; 'wrote:': 0.18; '>>>': 0.22; '&gt;&gt;&gt;': 0.24; 'integer': 0.24; '&gt;': 0.26; '2010,': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'am,': 0.29; 'received:209.85.217': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'twitter:': 0.31; 'skip:= 40': 0.31; 'url:python': 0.33; 'blog:': 0.33; "i'd": 0.34; 'received:209.85': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'skip:& 10': 0.38; 'nov': 0.38; 'to:addr :python-list': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'how': 0.40; 'skip:n 10': 0.64; 'more': 0.64; 'url:facebook': 0.67; 'url:gl': 0.72; 'url:goo': 0.75; 'article': 0.77; 'dar': 0.84; 'meu': 0.84; 'carlos': 0.91; 'facebook:': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=XgZGHqw8X2TC1LICxNXIl9T/HZuj3QfcKvHoRZmj1kY=; b=dZHvRJ0JKjGeRL/Orb9WQSEEJ4qBFdr0g2OvSP3zGM3Dmbq9ghvo8+dOkucftj+UMq wLqTQpa03lARVUa2DqQX/MUGiwD+5EicDpi4aWVe1U49p5fpHgkNi1nS1XrdRA64Aygs xO6K9+e3/Db7ptyWfkzsj275pneMVPge4WHCwfRHW3NnGTvjverNZz5oWocd19b3hoXY uy5AJP1QE1lj3pGzHEcanDB7e4A3J/aRikikpCxhf1TJIEmicj8TY5e3j6wScHi4rCdB 5eISo/6wcB3Ufeu6F/A6Rghdypfhd2Sp1oGaDDzqOklxc06nNgs9YvPq5/tMLXSPGgMt Dciw==
X-Received by 10.112.19.133 with SMTP id f5mr1359158lbe.98.1369137833727; Tue, 21 May 2013 05:03:53 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <nad-F52CE7.22440720052013@news.gmane.org>
References <BLU176-W10190CB892A0414C988A05D7A80@phx.gbl> <nad-F52CE7.22440720052013@news.gmane.org>
From Alysson Bruno <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
Content-Type multipart/alternative; boundary=14dae93d8c863a5e2804dd393e3a
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1921.1369137842.3114.python-list@python.org> (permalink)
Lines 146
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1369137842 news.xs4all.nl 16008 [2001:888:2000:d::a6]:43709
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45664

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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
>>>

paz e amor (love and peace),

Alysson Bruno
===============================================
Palmas(TO)
Brasil

Blog: http://abruno.com
Twitter: http://twitter.com/alyssonbruno
Facebook: http://www.facebook.com/ProfessorAlyssonBruno

=================================================================
*Meu alterego Escritor:*

Leia alguns contos que escrevo, não esqueça de me dar sua opinião:
http://goo.gl/Wjn4p <http://goo.gl/AXv1g>

=================================================================


On Tue, May 21, 2013 at 2:44 AM, Ned Deily <nad@acm.org> wrote:

> In article <BLU176-W10190CB892A0414C988A05D7A80@phx.gbl>,
>  Carlos Nepomuceno <carlosnepomuceno@outlook.com> wrote:
> > 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?
>
> For Python 3.2+ or 2.7, why not just:
>
> >>> print('Number = {:,}'.format(x))
> Number = 12,345
>
> --
>  Ned Deily,
>  nad@acm.org
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Re: PEP 378: Format Specifier for Thousands Separator Alysson Bruno <alyssonbruno@gmail.com> - 2013-05-21 09:03 -0300

csiph-web