with open('temp1-sorted.txt', 'r') as f2:
    with open('temp2-sorted.txt', 'r') as f3:
        with open('temp3-sorted.txt', 'r') as f4:
            with open(outfile, 'w') as of:
                of.writelines(heapq.merge(f1, f2, f3, f4))
Is there a way to simplify this "n-way merge" in python