"str.contains(part)" or alternatives?

Delaney, Timothy tdelaney at avaya.com
Wed Sep 11 19:37:17 EDT 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).

Tim Delaney

More information about the Python-list mailing list