feature request: string.contains('...')

John Posner jjposner at optimum.net
Fri Sep 24 10:10:26 EDT 2010


On 9/24/2010 4:21 AM, Peter Otten wrote:

>
> If you are not interested in the position of the substr use the "in"
> operator:
>
> if substr in s:
>      print "found"
> else:
>      print "not found"
>

Another "missing feature" candidate: sublist

    >>> 'bc' in 'abcde'
    True
    >>> list('bc') in list('abcde')
    False


A little Googling indicates that Haskell *does* have this feature: [1]


    ghci> [2,6] `isInfixOf` [3,1,4,1,5,9,2,6,5,3,5,8,9,7,9]
    True

I haven't located an equivalent Python idiom, though. I took a quick 
look through numpy, but no luck. Can anyone help?

Tx,
John

[1] http://book.realworldhaskell.org/read/functional-programming.html



More information about the Python-list mailing list