"str.contains(part)" or alternatives?
tdelaney at avaya.com
Thu Sep 12 01:37:17 CEST 2002
> From: Stefan Schwarzer [mailto:sschwarzer at sschwarzer.net]
> "if part in s" disturbs the pattern "if item in sequence"
> somewhat but that has
> already been weakened by "if key in dict" (that I like, nonetheless).
In fact, this was the deciding factor in Guido changing his position on 'if
s1 in s2'. A string has sequence-like behaviour (e.g. it is iterable,
individual characters can be indexed), but also has its own behaviour (e.g.
substring containment, all elements are single-character strings).
More information about the Python-list