Ping> I've been quite happy with "if key in dict". I forget if i Ping> already made this analogy when it came up in regard to the issue Ping> of supporting a "set" type, but if you think of it like a real Ping> dictionary -- when someone asks you if a particular word is "in Ping> the dictionary", you look it up in the keys of the dictionary, not Ping> in the definitions. Also, for many situations, "if value in dict" will be extraordinarily inefficient. In "in" semantics are added to dicts, a corollary move will be to extend this functionality to other non-dict mappings (e.g., file-based mapping objects like gdbm). Implementing "in" for them would be excruciatingly slow if the LHS was "value". To not break the rule of least astonishment when people push large dicts to disk, the only feasible implementation is "if key in dict". -- Skip Montanaro | http://www.mojam.com/ skip@mojam.com | http://www.musi-cal.com/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4