Python: os.tmpfile or tempfile.mkstemp
I want to open an external config file and present it to the user in an editor.
The solution I'm thinking about is creating a temporary file and copying the contents of the original file to it. The temporary file will then be opened for user editing in the default editor. This is all done because an incorrect configuration should never be written to the source file.
When the user saves the changes and closes the editor, the python script checks to see if the changes are valid and only overwrites the original file if so.
I have done some research and there seem to be two possibilities for creating a temporary file in python:
what is the difference between them? which one is better suited for this task? or is there a better way to do this?
source to share