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


Groups > comp.lang.python > #20104

Re: Formate a number with commas

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Neil Cerutti <neilc@norwich.edu>
Newsgroups comp.lang.python
Subject Re: Formate a number with commas
Date 9 Feb 2012 20:17:38 GMT
Organization Norwich University
Lines 17
Message-ID <9pinv2F5hpU2@mid.individual.net> (permalink)
References <eb1973ef-913e-408a-b491-d1449c8434e2@c21g2000yqi.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace individual.net b7DUkX4WHhZ+m3397XRFAAXHMwLU/S40MmqaZVdr6H+cGHHQW0
Cancel-Lock sha1:Tfbxz0FJMEJFBZ/SkMWdMqpGCiM=
User-Agent slrn/0.9.9p1/mm/ao (Win32)
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20104

Show key headers only | View raw


On 2012-02-09, noydb <jenn.duerr@gmail.com> wrote:
> How do you format a number to print with commas?
>
> Some quick searching, i came up with:
>
>>>> import locale
>>>> locale.setlocale(locale.LC_ALL, "")
>>>> locale.format('%d', 2348721, True)
> '2,348,721'
>
> I'm a perpetual novice, so just looking for better, slicker,
> more proper, pythonic ways to do this.

I think you've found an excellent way to do it.

-- 
Neil Cerutti

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