Hrvoje Niksic wrote:
> if test.contains(item) # would return a Boolean value
>
>> That's a string method, not a function in the string module.
Oops, of course.
>>>> import operator
>>>> operator.contains('foo', 'o')
That's pretty good, and IMHO a bit better than John Machin's suggestion
to use the __contains__() method. (I have this prejudice that using the
__XXX__ methods in "everyday code" is cheating.)
Given how common string maniuplations are, I guess I'm surprised that
Python hasn't yet made "contains()" into both a "string"-module function
*and* a string-object method.
--
http://mail.python.org/mailman/listinfo/python-list