Re: A little morning puzzle

Discussion in 'Python' started by Antoon Pardon, Sep 19, 2012.

  1. On 19-09-12 13:17, Neal Becker wrote:
    > I have a list of dictionaries. They all have the same keys. I want to find the
    > set of keys where all the dictionaries have the same values. Suggestions?

    common_items = reduce(opereator.__and__, [set(dct.iteritems()) for dct
    in lst])
    common_keys = set([item[0] for item in common_items])

    --
    Antoon Pardon
    Antoon Pardon, Sep 19, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neal Becker

    A little morning puzzle

    Neal Becker, Sep 19, 2012, in forum: Python
    Replies:
    2
    Views:
    172
    Paul Rubin
    Sep 19, 2012
  2. Peter Otten

    Re: A little morning puzzle

    Peter Otten, Sep 19, 2012, in forum: Python
    Replies:
    0
    Views:
    168
    Peter Otten
    Sep 19, 2012
  3. Dwight Hutto

    Re: A little morning puzzle

    Dwight Hutto, Sep 19, 2012, in forum: Python
    Replies:
    0
    Views:
    144
    Dwight Hutto
    Sep 19, 2012
  4. Peter Otten

    Re: A little morning puzzle

    Peter Otten, Sep 19, 2012, in forum: Python
    Replies:
    9
    Views:
    157
    Prasad, Ramit
    Sep 27, 2012
  5. Dwight Hutto

    Re: A little morning puzzle

    Dwight Hutto, Sep 19, 2012, in forum: Python
    Replies:
    0
    Views:
    151
    Dwight Hutto
    Sep 19, 2012
Loading...

Share This Page