[Python-ideas] [Python-Dev] hello, new dict addition for new eve ?

Terry Reedy tjreedy at udel.edu
Tue Jan 3 22:02:04 CET 2012

On 1/3/2012 11:59 AM, Nathan Rice wrote:
> This is slightly tangential, but I've always wondered... Why aren't
> set operations implemented on dicts?  It is fairly natural to view a
> dictionary as a set of (key, value) pairs.  Things like
> subset/superset checking (with concomitant operator support) make
> sense.  I have written stuff like set(dict1.items())<
> set(dict2.items()) many times.

As a said earlier in this thread, being able to view dicts as sets is 
such a good idea that it was already added a few years ago.

 >>> {1:1}.items() < {1:1, 2:2}.items()

> I don't even know what rich comparison operators on dictionaries do
> now, it isn't intuitive at all.

TypeError: unorderable types: dict() < dict()

Terry Jan Reedy

More information about the Python-ideas mailing list