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


Groups > comp.lang.python > #55363

Re: Rounding off Values of dicts (in a list) to 2 decimal points

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'assigning': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'sender:addr:gmail.com': 0.17; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'subject:) ': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'values.': 0.31; 'subject: (': 0.35; 'but': 0.35; 'received:google.com': 0.35; "you're": 0.61; 'back': 0.62; 'to:addr:gmail.com': 0.65
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=w2tRiISS5O5wmg8AOTvc9X9UX6ESx2LJ+AWun/AtjVQ=; b=mBCxwnQuvSbDZfo/V2McwzFSU6YQjLSAqTv+OwHgKGBrdu65BQu0Y+ZGhot+CmAEUc uf1wb4vmWcUAnpwJ/LbCO/qANwQzy6U6PNCnUGIcPCa4uHk1KF7OmBuip7dkUiCtsTro mtZI7H8m3T+rsCK6xz10wHaOBY86LL6cRS4lBAneL2nlABmlhsebpIT7nsLHp7ED3DeL tthBreYEVGbN1zkq8yHdIh3tDc/EY5EUbxMhlc3bIypu/Vju8xX4ZvdSxNhYphBMkmlZ HCNnyc0HC863KHGGlHHAXN1xmZCkF6iyuKyrbQgjtZGDbQYhqZhZ+4ZV8gbz2N1EvOrI pz7g==
MIME-Version 1.0
X-Received by 10.43.48.7 with SMTP id uu7mr1019677icb.68.1380733988178; Wed, 02 Oct 2013 10:13:08 -0700 (PDT)
Sender skip.montanaro@gmail.com
In-Reply-To <0aa3c507-a570-4d39-823d-106ba63b0b70@googlegroups.com>
References <0aa3c507-a570-4d39-823d-106ba63b0b70@googlegroups.com>
Date Wed, 2 Oct 2013 12:13:08 -0500
X-Google-Sender-Auth -B_nNP1L89EwdmxwNNPUKQ3hbNo
Subject Re: Rounding off Values of dicts (in a list) to 2 decimal points
From Skip Montanaro <skip@pobox.com>
To tripsvt@gmail.com
Content-Type text/plain; charset=UTF-8
Cc Python <python-list@python.org>
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.641.1380733997.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380733997 news.xs4all.nl 15979 [2001:888:2000:d::a6]:36042
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55363

Show key headers only | View raw


>     def roundingVals_toTwoDeci():
>         global y
>         for d in y:
>             for k, v in d.items():
>                 v = ceil(v*100)/100.0
>         return
>     roundingVals_toTwoDeci()
>
>
>
> But it is not working - I am still getting the old values.


You're not assigning the rounded value back into d. After assigning to
v try this:

    d[k] = v

Skip

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


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