def config_and_test(index): global file_name, DSTR, add_strat_nn, writer, scan_spec # checks if we have any more params to scan if index < len(params): # gets the current param, for instance epochs: [100,200,300] 100 200 and 300 are param for param in scan_spec[params[index]]: # metaprogramming stuff, just sets the param value, e.g. epoch = 100, then recurses down to the next index exec (params[index] + '=' + str(param)) config_and_test(index + 1) else: print settings.strategies # this part is broken, it should print what the current params are but I can't get it to work print settings.scan_spec # the file name is the current time file_name = datetime.datetime.now().strftime("%Y%m%d%H%M%S") full_name = os.path.join(os.path.join(os.path.dirname(__file__), 'test_csv'), file_name + '.csv') with open(full_name, 'wb') as csvfile: # initialize the writer, DSTR, neural network for each config we want to test writer = csv.writer(csvfile) writer.writerow(['Output Format Version', '20150807']) DSTR = Distribution() ADD.main() add_strat_nn = counting_network() test(settings.n_problems)