, l.index[a] . numpy : l[1] == b , , . array([ True, True], dtype=bool), , , .
, Python , , PyObject_RichCompareBool, , , , (a is b) (a == b). , , a is l[0], 0.
, . ( Ashwini Chaudhary ).
, , , l[0]:
d = array([0,1])
l.index(d)
, , .
, - , (index, in, remove) , , @orestiss. , numpy , :
>>> class NArray(object):
def __init__(self, arr):
self.arr = arr
def array(self):
return self.arr
def __eq__(self, other):
if (other.arr is self.arr):
return True
return (self.arr == other.arr).all()
def __ne__(self, other):
return not (self == other)
>>> a = array([0, 1])
>>> b = array([1, 0])
>>> l = [ NArray(a), NArray(b) ]
>>> l.index(NArray(a))
0
>>> l.index(NArray(b))
1