def dcross(**keywords):
 keys = keywords.keys()
 sequences = [keywords[key] for key in keys]
 wheels = map(iter, sequences)
 digits = [it.next() for it in wheels]
 while True:
  (yield dict(zip(keys, digits)))
  for i in range((len(digits) - 1), (-1), (-1)):
   try:
    digits[i] = wheels[i].next()
    break
   except StopIteration:
    wheels[i] = iter(sequences[i])
    digits[i] = wheels[i].next()
  else:
   break

def dcross ( ** keywords ) : keys = keywords . keys ( ) sequences = [ keywords [ key ] for key in keys ] wheels = map ( iter , sequences ) digits = [ it . next ( ) for it in wheels ] while True : ( yield dict ( zip ( keys , digits ) ) ) for i in range ( ( len ( digits ) - 1 ) , ( - 1 ) , ( - 1 ) ) : try : digits [ i ] = wheels [ i ] . next ( ) break except StopIteration : wheels [ i ] = iter ( sequences [ i ] ) digits [ i ] = wheels [ i ] . next ( ) else : break
similar to cross() .