[Guido] > ... > Surely you knew that "x in y" looped over the items of y? What else > could it have done? It was only defined on sequences! What's a sequence <wink>? I expect I assumed that enduring a Python method call for every element of an *instance* was so expensive that Python didn't bother implementing "in" for instances (just for builtin sequences like lists and strings etc). I *know* I assumed it was so expensive that I never tried it (indeed, I doubt I've used "[not] in" on *any* sort of sequence excepting "if x in s" where s was a tuple, list or string of length no more than 4; for anything bigger I always used a dict or bisect). So it's a personal blind spot likely due to never looking in that direction.
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