Why does Python show the whole array?

John Machin sjmachin at lexicon.net
Fri Apr 10 01:00:22 CEST 2009

On Apr 10, 2:36 am, John Posner <jjpos... at snet.net> wrote:
> 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.)

I "suggested" no such thing. You asked whether anyone had discussed
such a thing. A reply pointing out that such a thing exists already is
in no way inciting people to use it.

> 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.

Perhaps because there's already a good way to do it: stringa in stringb

More information about the Python-list mailing list