Since > < = returns masked arrays, you can propagate them together to get the effect you are looking for (essentially a logical AND):
>>> import numpy as np >>> A = 2*np.arange(10) array([ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) >>> idx = (A>2)*(A<8) >>> np.where(idx) array([2, 3])
source share