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

os.unlink

Prev: os.uname_result | Up: os | Next: os.urandom
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.unlink
Tags: #public #python3 #stdlib #os


Import

import os
from os import unlink

Signature & Overview

os.unlink(path, *, dir_fd=None)

Remove a file (same as remove()).

Usage

import os
from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as tmp:
    p = Path(tmp) / "temp.txt"
    p.write_text("x", encoding="utf-8")
    os.unlink(p)
    assert not p.exists()

Gotchas

REPL Inspect

from os import unlink
help(unlink)

Linked from

Related notes