[Python-ideas] tempfile.TemporaryDirectory() should be able to create temporary directory at a given arbitrary place

Steven D'Aprano steve at pearwood.info
Tue Jul 18 08:15:39 EDT 2017

On Tue, Jul 18, 2017 at 01:55:15PM +0200, George Fischhof wrote:
> Hi there,
> I used tempfile.TemporaryDirectory(). On first usage it was good, but on
> second one there was a need to create tempopray directory and files in it a
> given place. (It needed for a test).
> And I found that TemporaryDirectory() is not able to do this. So my idea is
> to implement this behaviour with an addittional path parameter in it.

Guido's Time Machine strikes again. TemporaryDirectory takes a dir 
argument to set the location where the temporary directory is created.


As far as I can tell, this functionality has existed as far back as 
Python 2.3:



More information about the Python-ideas mailing list