I am iterating through a list creating a bunch of temporary files at every iteration. At the end of the loop, I would like to append all these temporary files to a main temporary file. How do I append temporary files?
My attempt is below:
download_file = NamedTemporaryFile(mode='a')
for i in range(num_files):
temp_file = NamedTemporaryFile(mode='w+b')
# do some stuff
download_file.write(temp_file)
return download_file