def createFactorialTrialList(factors):
 tempListOfLists = [[]]
 for key in factors:
  alist = factors[key]
  tempList = []
  for value in alist:
   for iterList in tempListOfLists:
    tempList.append((iterList + [key, value]))
  tempListOfLists = tempList
 trialList = []
 for atrial in tempListOfLists:
  keys = atrial[0::2]
  values = atrial[1::2]
  atrialDict = {}
  for i in range(len(keys)):
   atrialDict[keys[i]] = values[i]
  trialList.append(atrialDict)
 return trialList

def createFactorialTrialList ( factors ) : tempListOfLists = [ [ ] ] for key in factors : alist = factors [ key ] tempList = [ ] for value in alist : for iterList in tempListOfLists : tempList . append ( ( iterList + [ key , value ] ) ) tempListOfLists = tempList trialList = [ ] for atrial in tempListOfLists : keys = atrial [ 0 : : 2 ] values = atrial [ 1 : : 2 ] atrialDict = { } for i in range ( len ( keys ) ) : atrialDict [ keys [ i ] ] = values [ i ] trialList . append ( atrialDict ) return trialList
create a triallist by entering a list of factors with names and levels it will return a triallist in which all factors have been factorially combined (so for example if there are two factors with 3 and 5 levels the triallist will be a list of 3*5 = 15 .