def output_params(folder): files = [each for each in os.listdir(folder) if each.endswith('.cpp')] output = '' for file in files: output += 'FILE: ' + folder + '/' + file + '\n\n' output += params.get_output(folder + '/' + file) output += '=========================================\n' text_file = open(folder + "/params_" + folder[4:] + ".txt", "w") text_file.write(output) text_file.close()