intersection, union, difference, symmetric difference for dictionaries

Grant Edwards invalid at invalid.invalid
Tue Feb 25 15:44:19 EST 2014


On 2014-02-25, mauro <mauro at gmail.com> wrote:
>  Dictionaries and sets share a few properties:
> - Dictionaries keys are unique as well as sets items
> - Dictionaries and sets are both unordered
> - Dictionaries and sets are both accessed by key
> - Dictionaries and sets are both mutables
>
> So I wonder why operations such us intersection, union, difference, 
> symmetric difference that are available for sets and are not available 
> for dictionaries without going via key dictviews. 

What would be the definition of the union, intersection, and
difference of these two dicts?

  {1:'blue', 2:'red'}
  {1:'green', 3:'yellow'}

-- 
Grant Edwards               grant.b.edwards        Yow! I smell like a wet
                                  at               reducing clinic on Columbus
                              gmail.com            Day!



More information about the Python-list mailing list