2 ms·
That's not what the parent says though. He says that sets are like dictionaries without values, e.g. a set is akin to the dictionary keys. So, in your example
by coldtea 8y ago
That's not what the parent says though.
He says that sets are like dictionaries without values, e.g. a set is akin to the dictionary keys.
So, in your example the ('a', 1) and ('a', 2) are the keys (in how the parent argues about) -- it's not 'a' that's the key.
Same like you can do today:
d = {}
d[('a', 1)] = 6
d[('a', 2)] = 89
We can still express that dictionary as a set of tuples, it's just:
{(('a', 1), 6), (('a', 2), 89)}
- 103e 8y agoMeant to respond to top level parent who said: > dicts would subclass sets Was trying to make the case as to why treating dictionaries as a child of <generic collection> with an extend/merge operation using ‘+’ rather than a child of set with a union operation ‘|’ makes more sense (to me). Changing the behaviour of a well defined operation like union seems bad - although my case is somewhat undermined by python’s overloading of ‘+’ to mean extend.