title: Get random key:value pairs from dictionary in python
body: <p>I'm trying to pull out a random set of key-value pairs from a dictionary I made from a csv file. The dictionary contains information for genes, with the gene name being the dictionary key, and a list of numbers (related to gene expression etc.) being the value.</p>
  
  <pre><code># python 2.7.5
  import csv
  import random
  
  genes_csv = csv.reader(open('genes.csv', 'rb'))
  
  genes_dict = {}
  for row in genes_csv:
      genes_dict[row[0]] = row[1:]
  
  length = raw_input('How many genes do you want? ')
  
  for key in genes_dict:
      random_list = random.sample(genes_dict.items(), int(length))
      print random_list
  </code></pre>
  
  <p>The problem is, if I try to get a list of 100 genes (for example), it seems to iterate over the whole dictionary and return every possible combination of 100 genes.</p>