Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55434
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-10-03 11:17 -0700 |
| References | <0aa3c507-a570-4d39-823d-106ba63b0b70@googlegroups.com> <23564349-7dd1-4d7a-9bfb-8483ddf3335e@googlegroups.com> <bb5pr5Fd36uU1@mid.individual.net> |
| Message-ID | <58286399-5eb3-40f8-9d28-e6036451fbf9@googlegroups.com> (permalink) |
| Subject | Re: Rounding off Values of dicts (in a list) to 2 decimal points |
| From | tripsvt@gmail.com |
On Thursday, October 3, 2013 11:03:17 AM UTC-7, Neil Cerutti wrote:
> On 2013-10-03, tripsvt@gmail.com <tripsvt@gmail.com> wrote:
>
> > thekey=[{"a": 80.0, "b": 0.0, "c": 10.0, "d": 10.0}, {"a":
>
> > 100.0, "b": 0.0, "c": 0.0, "d": 0.0}, {"a": 80.0, "b": 0.0,
>
> > "c": 10.0, "d": 10.0}, {"a": 90.0, "b": 0.0, "c": 0.0, "d":
>
> > 10.0}]
>
> >
>
> > However, at the URL, the values show up as 90.000043278694123
>
>
>
> You'll need to convert them to strings yourself before submitting
>
> them, by using % formatting or str.format.
>
>
>
> --
>
> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Rounding off Values of dicts (in a list) to 2 decimal points tripsvt@gmail.com - 2013-10-02 10:01 -0700
Re: Rounding off Values of dicts (in a list) to 2 decimal points Skip Montanaro <skip@pobox.com> - 2013-10-02 12:13 -0500
Re: Rounding off Values of dicts (in a list) to 2 decimal points Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-02 20:22 +0300
Re: Rounding off Values of dicts (in a list) to 2 decimal points Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-02 13:19 -0400
Re: Rounding off Values of dicts (in a list) to 2 decimal points Neil Cerutti <neilc@norwich.edu> - 2013-10-02 17:32 +0000
Re: Rounding off Values of dicts (in a list) to 2 decimal points tripsvt@gmail.com - 2013-10-03 10:06 -0700
Re: Rounding off Values of dicts (in a list) to 2 decimal points Peter Otten <__peter__@web.de> - 2013-10-03 19:41 +0200
Re: Rounding off Values of dicts (in a list) to 2 decimal points Neil Cerutti <neilc@norwich.edu> - 2013-10-03 18:03 +0000
Re: Rounding off Values of dicts (in a list) to 2 decimal points tripsvt@gmail.com - 2013-10-03 11:17 -0700
csiph-web