brian at sweetapp.com
Sun Aug 11 22:07:20 CEST 2002
> > def eqsub(s, i, j, t):
> > return (len(t) == j-i) and s[i:j] == t
> > which avoids building the substrings unless necessary.
> Wouldn't the following avoid it altogether?
> return (len(t) == j-i) and (s.find(t,i) != -1)
That code won't quite work. I believe that this code will though:
def eqsub(s, i, j, t):
return (len(t) == j-i) and (s.find(t,i,j) != -1)
I don't know if the length check saves you anything.
More information about the Python-list