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


Groups > comp.lang.python > #62034

Re: Comparing values of counter in python 3.3

References <7b7028b8-5de0-4a3a-a23b-2e19fe859955@googlegroups.com> <l8lmq6$6ps$1@dont-email.me> <905d6e7e-6748-42dd-8b63-d80a4d175914@googlegroups.com>
From Devin Jeanpierre <jeanpierreda@gmail.com>
Date 2013-12-16 01:50 -0800
Subject Re: Comparing values of counter in python 3.3
Newsgroups comp.lang.python
Message-ID <mailman.4195.1387187483.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Dec 15, 2013 at 6:32 PM, rusi <rustompmody@gmail.com> 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

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


Thread

Comparing values of counter in python 3.3 Amjad Syed <amjadcsu@gmail.com> - 2013-12-11 23:49 -0800
  Re: Comparing values of counter in python 3.3 Wolfgang Maier <xpysol@gmail.com> - 2013-12-12 01:55 -0800
    Re: Comparing values of counter in python 3.3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-12 10:11 +0000
  Re: Comparing values of counter in python 3.3 alex23 <wuwei23@gmail.com> - 2013-12-16 11:59 +1000
    Re: Comparing values of counter in python 3.3 rusi <rustompmody@gmail.com> - 2013-12-15 18:32 -0800
      Re: Comparing values of counter in python 3.3 Chris Angelico <rosuav@gmail.com> - 2013-12-16 13:37 +1100
      Re: Comparing values of counter in python 3.3 Roy Smith <roy@panix.com> - 2013-12-15 21:40 -0500
        Re: Comparing values of counter in python 3.3 rusi <rustompmody@gmail.com> - 2013-12-15 19:28 -0800
        Re: Comparing values of counter in python 3.3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-16 09:20 +0000
      Re: Comparing values of counter in python 3.3 Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-12-16 01:50 -0800

csiph-web