a = np.random.randint(-100, 100, size=100)
a[(a & 2 == 0) & (a > 0)]
Python does indeed have logical boolean operators.I think this is clearer than your Julia example because:
- The numpy version makes it clear that you are using random integers, not floating point values.
- The keyword argument for "size" makes it clear what that second 100 is for. (The use of the first two numbers, -100 and 100, is pretty clear from context.)
- In numpy, most operations are element-wise by default, because the result would be ambiguous or not useful otherwise. This removes the line noise of the extra "." before operations.
Don't get me wrong, I think Julia is awesome. I just think you've constructed a very poor example for numpy.