title: Random sample of paired lists in Python
body: <p>I have two lists <em>x</em> and <em>y</em>, both of length <em>n</em>, with <em>x<sub>i</sub></em> and <em>y<sub>i</sub></em> forming a pair. How could I take a random sample of <em>m</em> values from these two lists while preserving the pairing information (e.g. x[10] and y[10] would be together in the resulting sample) </p>
  
  <p>My initial idea is this.</p>
  
  <ul>
  <li>use zip to create a list of tuples</li>
  <li>shuffle the list of tuples</li>
  <li>select the first <em>m</em> tuples from the list</li>
  <li>break up the tuples into new paired lists</li>
  </ul>
  
  <p>And the code would look something like this.</p>
  
  <pre><code>templist = list()
  for tup in zip(x, y):
      templist.append(tup)
  random.shuffle(templist)
  x_sub = [a for a, b in templist[0:m]]
  y_sub = [b for a, b in templist[0:m]]
  </code></pre>
  
  <p>This seems rather kludgy to me. Is there any way I could make this more clear, concise, or Pythonic?</p>