X-Received: by 10.224.5.5 with SMTP id 5mr15200546qat.4.1380824274882; Thu, 03 Oct 2013 11:17:54 -0700 (PDT) X-Received: by 10.50.11.16 with SMTP id m16mr166008igb.0.1380824274655; Thu, 03 Oct 2013 11:17:54 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!a6no3087381qak.0!news-out.google.com!9ni4233qaf.0!nntp.google.com!a6no3087376qak.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Thu, 3 Oct 2013 11:17:54 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=64.71.23.190; posting-account=f-2-jgoAAAB01iAkif0b442Wwfv2co32 NNTP-Posting-Host: 64.71.23.190 References: <0aa3c507-a570-4d39-823d-106ba63b0b70@googlegroups.com> <23564349-7dd1-4d7a-9bfb-8483ddf3335e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <58286399-5eb3-40f8-9d28-e6036451fbf9@googlegroups.com> Subject: Re: Rounding off Values of dicts (in a list) to 2 decimal points From: tripsvt@gmail.com Injection-Date: Thu, 03 Oct 2013 18:17:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.python:55434 On Thursday, October 3, 2013 11:03:17 AM UTC-7, Neil Cerutti wrote: > On 2013-10-03, tripsvt@gmail.com wrote: >=20 > > thekey=3D[{"a": 80.0, "b": 0.0, "c": 10.0, "d": 10.0}, {"a": >=20 > > 100.0, "b": 0.0, "c": 0.0, "d": 0.0}, {"a": 80.0, "b": 0.0, >=20 > > "c": 10.0, "d": 10.0}, {"a": 90.0, "b": 0.0, "c": 0.0, "d": >=20 > > 10.0}] >=20 > > >=20 > > However, at the URL, the values show up as 90.000043278694123 >=20 >=20 >=20 > You'll need to convert them to strings yourself before submitting >=20 > them, by using % formatting or str.format. >=20 >=20 >=20 > --=20 >=20 > Neil Cerutti I thought the class 'LessPrecise' converts them to strings. But even when I= try doing it directly without the class at all, as in str(round(v, 2)), it= gives all the expected values (as in {"a": "10.1", "b": "3.4", etc.}) but = at the URL, it gives all the decimal places - 10.78324783923783