title: Cartesian product in Gray code order with itertools?
body: <p>Is there something like Python's <code>itertools.product()</code> that provides the iteration through the Cartesian product of a set of sets in <em>Gray code order</em>?  For example, supposing that such a hypothetical generator existed, and it was called <code>gray_code_product()</code>, then <code>gray_code_product(['a','b','c'], [0,1], ['x','y'])</code> would generate, in the order :</p>
  
  <pre><code>('a',0,'x')
  ('a',0,'y')
  ('a',1,'y')
  ('a',1,'x')
  ('b',1,'x')
  ('b',1,'y')
  ('b',0,'y')
  ('b',0,'x')
  ('c',0,'x')
  ('c',0,'y')
  ('c',1,'y')
  ('c',1,'x')
  </code></pre>