MATLAB-style find() function in Python
You can make a function that takes a callable parameter which will be used in the condition part of your list comprehension. Then you can use a lambda or other function object to pass your arbitrary condition:
def indices(a, func): return [i for (i, val) in enumerate(a) if func(val)]a = [1, 2, 3, 1, 2, 3, 1, 2, 3]inds = indices(a, lambda x: x > 2)>>> inds[2, 5, 8]
It's a little closer to your Matlab example, without having to load up all of numpy.