On 5/28/2011 3:40 PM, Robert wrote: > (myarray in mylist) turns into mylist.__contains__(myarray). > Only the list object is ever checked for this method. There is no > paired method myarray.__rcontains__(mylist) so there is nothing that > numpy can override to make this operation do anything different from > what lists normally do, which is check if the given object is equal to > one of the items in the list.
This seems to me to slightly miscast the problem. How would an __rcontains__ method really fix things? Would the list type check against a table of stuff that it knows how to contain? That seems horrible. And even if possible, NumPy would then have to break the rule that ``in`` tests for equality, because (I believe) the real problem in this case is that np equality testing does not return a bool. From this perspective, what is missing is not __rcontains__ (since the list already knows what to do) but rather __eeq__ for element-by-element comparison (ideally, along with an element-by-element operator such as say .==). In the meantime the OP could use any(all(a==x) for x in lst) fwiw, Alan Isaac _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion