15 Mar
2006
15 Mar
'06
4:51 p.m.
Erin Sheldon wrote:
Nice. Python decides to compare with the keys and not the values.
Sure. It is a ridiculously common to ask a dictionary if it has a record for a particular key. It is much, much rarer to ask one if it has a particular value. Lists, tuples, and sets, on the other hand, only have one kind of interesting data, the values, so the __contains__ method operates on values with them. Practicality beats purity, in this case.
The possibilities for obfuscation are endless.
Not in my experience. -- Robert Kern robert.kern@gmail.com "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco