Lawrence D'Oliveiro wrote:
In message <8h9ob9fku...@mid.individual.net>, Gregory Ewing wrote:
Lawrence D'Oliveiro wrote:

Did you know that applying the “set” or “frozenset” functions to a dict
return a set of its keys?
Seems a bit dodgy, somehow.
That's just a consequence of the fact that dicts produce their
keys when iterated over, and the set constructor iterates over
whatever you give it.
Hmm. It seems that “iter(<dict>)” iterating over the keys has been around a 
long time. But a dict has both keys and values: why are language constructs 
treating them so specially as to grab the keys and throw away the values?
What's so special about it?  If you want the value, ask for it; 
iterating over the dict without asking specifically for the values does 
not give them.  Furthermore, if you did get the key:value pairs how 
would you store them in a set such that you could query the set to see 
if a key were there?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to