title: How to get all mappings between two lists?
body: <p>We have two lists, A and B:</p>
  
  <pre><code>A = ['a','b','c']
  B = [1, 2]
  </code></pre>
  
  <p>Is there a pythonic way to build the set of all maps between A and B containing 2^n (here 2^3=8)? That is:</p>
  
  <pre><code>[(a,1), (b,1), (c,1)]
  [(a,1), (b,1), (c,2)]
  [(a,1), (b,2), (c,1)]
  [(a,1), (b,2), (c,2)]
  [(a,2), (b,1), (c,1)]
  [(a,2), (b,1), (c,2)]
  [(a,2), (b,2), (c,1)]
  [(a,2), (b,2), (c,2)]
  </code></pre>
  
  <p>Using <code>itertools.product</code>, it's possible to get all the tuples:</p>
  
  <pre><code>import itertools as it
  P = it.product(A, B)
  [p for p in P]
  </code></pre>
  
  <p>Which gives:</p>
  
  <pre><code>Out[3]: [('a', 1), ('a', 2), ('b', 1), ('b', 2), ('c', 1), ('c', 2)]
  </code></pre>