On this page
  1. tempfile.mkdtemp
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

tempfile.mkdtemp

Prev: tempfile.gettempprefixb | Up: tempfile | Next: tempfile.mkstemp
Rel: tempfile.gettempdir, tempfile.gettempdirb, tempfile.gettempprefix, tempfile.gettempprefixb
Ref: docs.python.org — tempfile.mkdtemp
Tags: #public #python3 #stdlib #tempfile


Import

import tempfile
from tempfile import mkdtemp

Signature & Overview

tempfile.mkdtemp(suffix=None, prefix=None, dir=None)

User-callable function to create and return a unique temporary directory. The return value is the pathname of the directory.

Usage

from pathlib import Path
import shutil
import tempfile

d = Path(tempfile.mkdtemp(prefix="work_"))
try:
    assert d.is_dir()
finally:
    shutil.rmtree(d)

Gotchas

REPL Inspect

from tempfile import mkdtemp
help(mkdtemp)

Linked from

Related notes