On 5 Aug 2002 at 15:27, Tim Peters wrote: > >> and I expect *everyone* here has been saved more > >> than once by that > >> > >> '' in 'xyz' > >> currently raises an exception. Not that I can recall. The exception, however, is a TypeError saying the left operand isn't a character. It's not a TrueButYourProbablyMakingAMistakeException <wink>. > I'd like to see a plausible use case for > > '' in str > > returning True, then. Any code that currently does str.find(x) >= 0 I tend to use: pos = str.find(x) if pos > -1: because I'm normally interested in where. If it's a pure membership test, I tend not to use a string but a tuple: if c in ('a', 'b', 'c'): This is, at least partially, because "character" is not an official Python type so I always expect str1 in str2 to work when it only sometimes does. -- Gordon http://www.mcmillan-inc.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