Robert Kern wrote:
James Stroud wrote:
I think it skips straight to __eq__ if the element is not the first in
the list.
No, it doesn't skip straight to __eq__(). "y is 1" returns False, so
(y==1) is checked. When y is a numpy array, this returns an array of
bools. list.__contains__() tries to convert this array to a bool and
ndarray.__nonzero__() raises the exception.
list.__contains__() checks "is" then __eq__() for each element before
moving on to the next element. It does not try "is" for all elements,
then try __eq__() for all elements.
Ok. Thanks for the explanation.
> That no one acknowledges this makes me feel like a conspiracy
> is afoot.
I don't know what you think I'm not acknowledging.
Sorry. That was a failed attempt at humor.
James
--
http://mail.python.org/mailman/listinfo/python-list