Description
Feature or enhancement
Proposal:
Hey.
Using the the automatic cleanup of NamedTemporaryFile
simplifies handling of the created temporary files obviously a lot.
There are however use cases, where sometimes it may be found after the named temp file has been created, that it actually shouldn’t be temporary but kept and maybe even moved to another name.
Consider that you want to update a local file from a downloaded source. You may first want to download from the remote location to some temporary file, then diff the two, and only if there are some differences, move the file to the local one (thereby overwriting that) and then do some extra processing of it.
Right now, there seems no documented/stable way of doing this:
- currently it seems to work by just moving the temporary file to another location... but a future version may do something like unlinkat() and delete the file using an open FD.
- One can set
k._closer.delete = False
but that is of course also not part of the public API.
I think it would be nice to have these properties exported under some proper public name or - at least documented to be part of the usable API, despite the underscore.
Thanks,
Chris.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response