user277465
user277465

Reputation:

using a "temporary files" folder in python

I recently wrote a script which queries PyPI and downloads a package; however, the package gets downloaded to a user defined folder.

I`d like to modify the script in such a way that my downloaded files go into a temporary folder, if the folder is not specified.

The temporary-files folder in *nix machines is "/tmp" ; would there be any Python method I could use to find out the temporary-files folder in a particular machine?

If not, could someone suggest an alternative to this problem?

Upvotes: 3

Views: 4174

Answers (2)

Matt Ball
Matt Ball

Reputation: 359816

Python has a built-in module for using temporary files and folders. You probably want tempfile.mkdtemp().

Upvotes: 9

Nicholas Riley
Nicholas Riley

Reputation: 44321

Perhaps the tempfile module?

Upvotes: 0

Related Questions