Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12011
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <przemolicc@poczta.fm> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.113 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.79; '*S*': 0.02; '>>>>': 0.09; 'locale': 0.09; 'trailing': 0.09; 'zeros': 0.09; '0.1)': 0.16; 'mon,': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'aug': 0.24; 'skip:l 30': 0.24; '(the': 0.28; 'import': 0.28; 'print': 0.29; '+0200,': 0.30; '22,': 0.30; 'format:': 0.30; 'to:addr :python-list': 0.33; 'header:User-Agent:1': 0.34; 'but': 0.37; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.63; 'charset:iso-8859-2': 0.66; 'subject:without': 0.67; 'strange': 0.68; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'received:pl': 0.84; 'otten': 0.84; 'subject:skip:l 10': 0.84; 'url:pl': 0.93 |
| Date | Mon, 22 Aug 2011 13:29:58 +0200 |
| From | przemolicc@poczta.fm |
| To | python-list@python.org |
| Subject | Re: locale.format without trailing zeros |
| References | <mailman.303.1314005406.27778.python-list@python.org> <j2t8lo$99c$1@solani.org> |
| MIME-Version | 1.0 |
| In-Reply-To | <j2t8lo$99c$1@solani.org> |
| User-Agent | Mutt/1.5.18 (2008-05-17) |
| X-Interia-Antivirus | OK |
| X-EMID | 351efc98 |
| Content-Type | text/plain; charset="iso-8859-2" |
| Content-Transfer-Encoding | quoted-printable |
| Content-Disposition | inline |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | przemolicc@poczta.fm |
| 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.310.1314012601.27778.python-list@python.org> (permalink) |
| Lines | 91 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1314012601 news.xs4all.nl 23850 [2001:888:2000:d::a6]:52786 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12011 |
Show key headers only | View raw
On Mon, Aug 22, 2011 at 11:48:46AM +0200, Peter Otten wrote:
> przemolicc@poczta.fm wrote:
>
> >>>> import locale
> >>>> locale.setlocale(locale.LC_ALL, "pl_PL")
> > 'pl_PL'
> >>>> i=0.20
> >>>> j=0.25
> >>>> locale.format('%f', i)
> > '0,200000'
> >>>> locale.format('%f', j)
> > '0,250000'
> >
> > I need to print the numbers in the following format:
> > '0,2' (i)
> > '0,25' (j)
> > So the last trailing zeros are not printed.
>
> >>> print locale.format("%g", 1.23)
> 1,23
> >>> print locale.format("%g", 1.2345678)
> 1,23457
> >>> print locale.format("%.10g", 1.2345678)
> 1,2345678
> >>> print locale.format("%.15g", 0.1)
> 0,1
> >>> print locale.format("%.17g", 0.1)
> 0,10000000000000001
How about this format:
',1'
(the local zero is also not printed)
(I know this is strange but I need compatibility with local requirements)
Regards
Przemyslaw Bak (przemol)
----------------------------------------------------------------
Najwieksza baza najtanszych ofert mieszkaniowych
http://linkint.pl/f2a0e
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
locale.format without trailing zeros przemolicc@poczta.fm - 2011-08-22 10:52 +0200
Re: locale.format without trailing zeros Peter Otten <__peter__@web.de> - 2011-08-22 11:48 +0200
Re: locale.format without trailing zeros przemolicc@poczta.fm - 2011-08-22 13:08 +0200
Re: locale.format without trailing zeros przemolicc@poczta.fm - 2011-08-22 13:29 +0200
Re: locale.format without trailing zeros Peter Otten <__peter__@web.de> - 2011-08-22 15:01 +0200
Re: locale.format without trailing zeros Anssi Saari <as@sci.fi> - 2011-08-22 13:59 +0300
csiph-web