[Tutor] Can tempfile.NamedTemporaryFile(delete=False) be used to create *permanent* uniquely named files?

Cameron Simpson cs at cskk.id.au
Sun Oct 21 19:02:58 EDT 2018


On 21Oct2018 10:55, Peter Otten <__peter__ at web.de> wrote:
>boB Stepp wrote:
>> So I am now wondering if using
>> tempfile.NamedTemporaryFile(delete=False) would solve this problem
>> nicely?  As I am not very familiar with this library, are there any
>> unforeseen issues I should be made aware of?  Would this work equally
>> well on all operating systems?
>
>I think this is cool thinking outside of the box.
>
>I would not have "dared" this, but now you suggest it I cannot see anything
>wrong with your approach.

The doco for mktemp (do not use! use mkstemp or the NamedTemporaryFile 
classes instead!) explicitly mentions using delete=False.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list