[Gordon McMillan] > Turns out that's not true. When I want set membership, > I first write "char in ('a', 'b', 'c')", then > sometimes change it because "char in 'abc'" is more > efficient. "char in dict_acting_as_a_set" is faster still, if you're really keen to speed it. > So whether '' in 'abc' will work or not is a red > herring. For your particular use, possibly. If "char" is computed and may become empty by mistake, then it's not a red herring (it's the difference between getting True and getting an exception). > The real issue is that membership gets conflated with subsetting. For strings, yes, if you change it to "the membership meaning goes away entirely in general, and a substring meaning replaces it". If "char" is computed and may become longer than one character by mistake, then in your use something that used to raise an exception would instead return True or False, depending on the data values.
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