[Python-Dev] Re: Generalizing "in" to pairs of sequences

Barry A. Warsaw barry@zope.com
Sun, 26 Aug 2001 23:07:30 -0400

    ESR> You're right.  But since a string can't be an element of a
    ESR> string, the case I'm really interested in would still work.

    KY> It's arguable.  A character can indeed be an element of a
    KY> string, and in Python characters are one-character strings.
    KY> So this violates

    KY>     x in s <=> there exists i such that s[i] == x

    KY> You could argue that strings should have special behaviour for
    KY> "in" to support the common case of finding a substring; then
    KY> you would have to argue on grounds of "practicality beats
    KY> purity".

And against TOOWTDI:

>>> 'cabcd'.find('ab') >= 0
>>> 'cabcd'.find('xx') >= 0