Why does Python show the whole array?

John Posner jjposner at snet.net
Thu Apr 9 10:35:01 EDT 2009


Lawrence D'Oliveiro wrote:

 > Fine if it only happened once. But it's a commonly-made mistake. At some
 > point you have to conclude that not all those people are stupid, there
 > really is something wrong with the design.

I think "something wrong with the design" is overstating the case a bit, 
and is likely to elicit some negative reactions in this forum. But I 
agree with your point, to this extent: this situation illustrates the 
way in which Python "overloads" the number zero:

  Realm A:  "0" indicates the first position in a sequence
  Realm B:   "0" indicates the Boolean value "False"

You just need to remember that the find() function works in Realm A, and 
the "in" operator works in Realm B.

Q: Has anyone on the python-dev list ever proposed a "string"-module 
function that does the job of the "in" operator? Maybe this:

  if test.contains(item)     # would return a Boolean value




More information about the Python-list mailing list