Why does Python show the whole array?

andrew cooke andrew at acooke.org
Thu Apr 9 13:11:22 EDT 2009


Peter Otten wrote:
> John Posner wrote:
>
>> 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.
>
> Could you explain why you prefer 'contains(belly, beer)'
> or 'belly.contains(beer)' over 'beer in belly'? The last form may be a bit
> harder to find in the documentation, but once a newbie has learned about
> it
> he'll find it easy to remember.

i don't know why i get involved in this type of discussion, but....

while i agree that "in" is the correct answer, i am not sure it's obvious
or easy to remember once you know it.  perhaps to a newbie with a sweet,
innocent and unsullied mind.  but for an already corrupted programmer like
myself, it's not easy to remember - i keep forgetting it!  i think it's
because i associate "in" with iteration, and assume everything else will
be method calls or functions (and from earlier discussions here, it's
clear some people are even more blinkered, and think everything should be
methods....)

so yeah, "in" is right, but arguments about what is natural and easy
aren't really worth wasting bits over...

andrew





More information about the Python-list mailing list