Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '16,': 0.03; 'reject': 0.07; 'cc:addr:python-list': 0.11; '2)]': 0.16; "[('a',": 0.16; 'subject:3.3': 0.16; 'subject:values': 0.16; 'subtraction': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; '15,': 0.26; 'compare': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'monday,': 0.33; 'december': 0.35; 'received:google.com': 0.35; 'skip:[ 10': 0.38; 'pm,': 0.38; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'rusi': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=GuicWXM0bmnv2gpldmxE08CwrR1rEKRAhdfzTrPOkaI=; b=hJ4mAMeJQ2wyLrBgISTyIP0kShn8RnVfAxyYJXNmEZU5IA0Ec4MXP0VJchXYjInwAm NnBCN2tmDerJOpgfDKtHTi0i3TAX2RPVZhAc0emll+YRD6JA5CgKcTY7UJArzliorYgv h2gN9xbe1bnCjDRG2YheeD+cLSsyVLzXm2zNSHeqamI/92ffhJyrXGeY9NiuBRF+OcIi 26xSEgDe6E5DYQIAK7Nzmoyt6nm54C6NPqAuG65pzg+mtLXCDIjnxagDgzBMoTRIoG0G LFBSthtFXxxoJ9ZVg6Ut104FDyJs7+fN7eZPPxhEK6Oxx//Rhj4AWrIYfRzrrf88nSE8 LstA== X-Received: by 10.224.67.137 with SMTP id r9mr31001036qai.8.1387187481596; Mon, 16 Dec 2013 01:51:21 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <905d6e7e-6748-42dd-8b63-d80a4d175914@googlegroups.com> References: <7b7028b8-5de0-4a3a-a23b-2e19fe859955@googlegroups.com> <905d6e7e-6748-42dd-8b63-d80a4d175914@googlegroups.com> From: Devin Jeanpierre Date: Mon, 16 Dec 2013 01:50:41 -0800 Subject: Re: Comparing values of counter in python 3.3 To: rusi Content-Type: text/plain; charset=UTF-8 Cc: "comp.lang.python" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387187483 news.xs4all.nl 2901 [2001:888:2000:d::a6]:35448 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62034 On Sun, Dec 15, 2013 at 6:32 PM, rusi wrote: > On Monday, December 16, 2013 7:29:31 AM UTC+5:30, alex23 wrote: >> > # Need to compare values of counter and reject in function/routine in value in counter2 is higher then value in counter1 for a current key > >> [(k,Counter2[k]) for k in Counter2 - Counter1] > > Why not just? > > Counter2 - Counter1 > > And if you want to uncounterify it then > dict(Counter2 - Counter1) Because you get different counts. >>> c1 = Counter('ab') >>> c2 = Counter('aab') >>> c2 - c1 Counter({'a': 1}) >>> [(k, c2[k]) for k in c2 - c1] [('a', 2)] Counter subtraction is multiset subtraction, not set subtraction. -- Devin