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


Groups > comp.lang.python > #40719

Re: Insert comma in number?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'locale': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:number': 0.09; '","': 0.16; '"."': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.17; 'specify': 0.17; 'windows': 0.19; 'import': 0.21; 'example': 0.23; 'work.': 0.23; 'paul': 0.24; 'least': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; "skip:' 10": 0.30; 'system,': 0.32; 'german': 0.32; '"")': 0.33; 'to:addr:python-list': 0.33; 'skip:l 30': 0.35; 'subject:?': 0.35; 'received:org': 0.36; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'option': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'mind:': 0.84; 'otten': 0.84; 'employ': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Insert comma in number?
Date Thu, 07 Mar 2013 09:58:24 +0100
Organization None
References <9c8df3b5-510a-4d00-a3ff-0c59799dcded@googlegroups.com> <kh9h53$r38$1@ger.gmane.org> <CAK38ikRVMhjFEgh_KKQzLBQ0Pp9rQRc-Nvs_OTk+vVRy4HRU9A@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084a660.dip.t-dialin.net
User-Agent KNode/4.7.3
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.2988.1362646692.2939.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362646692 news.xs4all.nl 6888 [2001:888:2000:d::a6]:59108
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40719

Show key headers only | View raw


Paul Volkov wrote:

> 2013/3/7 Peter Otten <__peter__@web.de>:
>> Last not least there's the option to employ locale-aware formatting:
>>
>>>>> import locale
>>>>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
>> 'en_US.UTF-8'
>>>>> locale.format("%d", 12345, grouping=True)
>> '12,345'
>>
>> In German usage of "." and "," is reversed, so:
>>
>>>>> locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
>> 'de_DE.UTF-8'
>>>>> locale.format("%d", 12345, grouping=True)
>> '12.345'
> 
> Does this locale-aware example only work on UNIX?

If you have Windows in mind: I don't know what it takes to get multiple 
locales on a Windows system, but for the default locale that you can specify 
with

locale.setlocale(locale.LC_ALL, "")

it should work.

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


Thread

Insert comma in number? eli m <techgeek201@gmail.com> - 2013-03-06 15:39 -0800
  Re: Insert comma in number? ian douglas <iandouglas736@gmail.com> - 2013-03-06 15:51 -0800
  Re: Insert comma in number? Chris Rebert <clp2@rebertia.com> - 2013-03-06 16:07 -0800
  Re: Insert comma in number? Terry Reedy <tjreedy@udel.edu> - 2013-03-06 20:28 -0500
  Re: Insert comma in number? Peter Otten <__peter__@web.de> - 2013-03-07 08:55 +0100
  Re: Insert comma in number? Paul Volkov <capt-obvious@yandex.ru> - 2013-03-07 12:30 +0400
  Re: Insert comma in number? Peter Otten <__peter__@web.de> - 2013-03-07 09:58 +0100

csiph-web