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


Groups > comp.lang.python > #20116

Re: Formate a number with commas

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.027
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'python': 0.08; 'locale': 0.09; 'url:peps': 0.09; '2.7': 0.13; 'comma': 0.16; 'cc:addr :python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'feb': 0.22; 'received:209.85.212.46': 0.23; 'received:mail- vw0-f46.google.com': 0.23; 'correct,': 0.23; 'pep': 0.23; 'url:dev': 0.23; 'do,': 0.25; 'cc:2**0': 0.26; 'import': 0.27; 'message-id:@mail.gmail.com': 0.29; "skip:' 10": 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'ran': 0.30; 'subject:number': 0.30; 'chris': 0.30; 'actually': 0.31; 'skip:l 30': 0.32; 'thu,': 0.32; 'received:209.85.212': 0.33; 'latter': 0.34; 'skip:" 20': 0.35; 'url:python': 0.35; 'but': 0.37; 'machine': 0.37; 'received:google.com': 0.37; 'skip:" 10': 0.37; 'subject:with': 0.37; 'received:209.85': 0.38; 'should': 0.38; 'url:org': 0.39; 'received:209': 0.39; 'together.': 0.40; '12:39': 0.84; '378': 0.84; 'otten': 0.84; 'sender:addr:chris': 0.84; 'technically': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=OUy6Tx1SuDcvFZDf6oBdrOkZ/2uxJn/Y5IBkZSqNSA4=; b=aJyT+NHxZiGVx3KKGgRuaRvmspSJYni0PJ3K9zApcmEJeJSMXUB3dwsME2KjSyzdvC vh/JN0tC85R7Gk4tiNP5e6p3vvp2KHTqMKEfc9LHJbcYSWdqy2I1wGeUiZKNLSVeyg/2 E/ozTWjk3lONoJuyZKVfItCgnsnBsr81TAzVU=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <jh1d2h$9eb$2@dough.gmane.org>
References <eb1973ef-913e-408a-b491-d1449c8434e2@c21g2000yqi.googlegroups.com> <jh1at1$rai$1@dough.gmane.org> <CAMZYqRRQ9MPwV+mCmXmoWc+swNc=Y5LrMzQPSr4dgC-TtiqErw@mail.gmail.com> <jh1d2h$9eb$2@dough.gmane.org>
Date Thu, 9 Feb 2012 14:12:35 -0800
X-Google-Sender-Auth mORZ652t1eHgtTBZ_JSfR8kuSos
Subject Re: Formate a number with commas
From Chris Rebert <clp2@rebertia.com>
To Peter Otten <__peter__@web.de>
Content-Type text/plain; charset=UTF-8
X-Gm-Message-State ALoCoQlGqqlijlL4XojWoH3+keAqjdySDiHRrpiYv3BQGwi0RrTzck/I0E+1ho+RVCQAG8fJezOQ
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.5617.1328825558.27778.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328825558 news.xs4all.nl 6917 [2001:888:2000:d::a6]:48189
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20116

Show key headers only | View raw


On Thu, Feb 9, 2012 at 1:16 PM, Peter Otten <__peter__@web.de> wrote:
> Chris Rebert wrote:
>> On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__@web.de> wrote:
>>>>>> import locale
>>>>>> locale.setlocale(locale.LC_ALL, "")
>>> 'de_DE.UTF-8'
>>>>>> "{:n}".format(1234) # locale-aware
>>> '1.234'
>>>>>> "{:,d}".format(1234) # always a comma
>>> '1,234'
>>
>> The latter requires Python 3.1+ and is courtesy PEP 378
>> (http://www.python.org/dev/peps/pep-0378/ ).
>
> I actually ran the above session in 2.7, so that should do, too.
>
> http://docs.python.org/whatsnew/2.7.html#pep-378-format-specifier-for-
> thousands-separator

Argh. The 2.7 docs say it was added in 2.7, but the 3.3a0 docs say it
was added in 3.1 (Guido's backporting time machine messes with
"causality").
Both statements are completely technically correct, but misleading
when not taken together.

Cheers,
Chris

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


Thread

Formate a number with commas noydb <jenn.duerr@gmail.com> - 2012-02-09 12:08 -0800
  Re: Formate a number with commas Neil Cerutti <neilc@norwich.edu> - 2012-02-09 20:17 +0000
  Re: Formate a number with commas Peter Otten <__peter__@web.de> - 2012-02-09 21:39 +0100
  Re: Formate a number with commas Chris Rebert <clp2@rebertia.com> - 2012-02-09 12:51 -0800
  Re: Formate a number with commas Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-02-09 22:13 +0100
  Re: Formate a number with commas Peter Otten <__peter__@web.de> - 2012-02-09 22:16 +0100
  Re: Formate a number with commas Chris Rebert <clp2@rebertia.com> - 2012-02-09 14:12 -0800
  Re: Formate a number with commas John Posner <jjposner@optimum.net> - 2012-02-09 17:57 -0500
  Re: Formate a number with commas Terry Reedy <tjreedy@udel.edu> - 2012-02-09 22:06 -0500

csiph-web