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

tempfile.mktemp

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


Import

import tempfile
from tempfile import mktemp

Signature & Overview

tempfile.mktemp(suffix='', prefix='tmp', dir=None)

User-callable function to return a unique temporary file name. The file is not created.

Usage

import tempfile

# Legacy/insecure: prefer NamedTemporaryFile or TemporaryDirectory instead
with tempfile.NamedTemporaryFile(suffix=".txt") as f:
    assert f.name.endswith(".txt")

Gotchas

REPL Inspect

from tempfile import mktemp
help(mktemp)

Linked from

Related notes