Why does Python show the whole array?

John Posner jjposner at snet.net
Thu Apr 9 18:36:24 CEST 2009

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.

More information about the Python-list mailing list