def iterCombinations(tup):
 if (len(tup) == 1):
  for i in range(tup[0]):
   (yield (i,))
 elif (len(tup) > 1):
  for prefix in iterCombinations(tup[:(-1)]):
   for i in range(tup[(-1)]):
    (yield tuple((list(prefix) + [i])))

def iterCombinations ( tup ) : if ( len ( tup ) == 1 ) : for i in range ( tup [ 0 ] ) : ( yield ( i , ) ) elif ( len ( tup ) > 1 ) : for prefix in iterCombinations ( tup [ : ( - 1 ) ] ) : for i in range ( tup [ ( - 1 ) ] ) : ( yield tuple ( ( list ( prefix ) + [ i ] ) ) )
all possible of integer tuples of the same dimension than tup .