Skip to content

Tag: temp

Copying a NamedTemporaryFile in Linux results in empty file

I am writing some contents to a tempfile.NamedTemporaryFile in Python 3 under Ubuntu 16.04. Under certain circumstances, I want to copy that file to a different location after the writing is done. The problem is reproduced with the following code: mytest.txt is empty once the execution is over. If I use delet…