def run_random_fofn(output_fofn, output_dir, nfofns): fofns = [] for i in xrange(nfofns): name = "random_{i}".format(i=i) file_name = ".".join([name, 'fofn']) p = os.path.join(output_dir, file_name) with open(p, 'w+') as w: w.write(name) fofns.append(p) M.write_fofn(output_fofn, fofns) return 0