title: Pythonic way to select elements of an array based on values?
body: <p>I'm looking for a pythonic (1-line) way to extract a range of values from an array
  Here's some sample code that will extract the array elements that are >2 and &lt;8 from x,y data, and put them into a new array.  Is there a way to accomplish this on a single line?  The code below works but seems kludgier than it needs to be. (Note I'm actually working with floats in my application)</p>
  
  <pre><code>import numpy as np
  
  x0 = np.array([0,3,9,8,3,4,5])
  y0 = np.array([2,3,5,7,8,1,0])
  
  x1 = x0[x0&gt;2]
  y1 = y0[x0&gt;2]
  x2 = x1[x1&lt;8]
  y2 = y1[x1&lt;8]
  
  print x2, y2
  </code></pre>
  
  <p>This prints </p>
  
  <pre><code>[3 3 4 5] [3 8 1 0]
  </code></pre>
  
  <p>Part (b) of the problem would be to extract values say <code>1 &lt; x &lt; 3</code>  <em>and</em> <code>7 &lt; x &lt; 9</code> as well as their corresponding <code>y</code> values.</p>