Martin Panter added the comment:
I think I have often passed delete=False because of the documented deficiency
with Windows (see Issue 14243). Depending on the outcome of that issue,
allowing for deletion after close() might be useful too.
BTW, monkey-patching __del__() probably won’t work if
Stephen Gallagher added the comment:
Oops, the temporary code I sent indicated that I was overriding the unlink()
function (which I also tried, just in case __del__ was somehow protected).
Neither monkeypatching unlink nor __del__ actually worked.
--
__
New submission from Stephen Gallagher:
Currently, NamedTemporaryFile takes an attribute at initialization that allows
it to remove the temporary file on going out of scope or else leave it around.
However, it's not possible to change this after the fact.
It would be a much more sensible patter