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

os.access

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


Import

import os
from os import access

Signature & Overview

os.access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)

Use the real uid/gid to test for access to a path.

Usage

import os
from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as tmp:
    p = Path(tmp) / "file.txt"
    p.write_text("ok", encoding="utf-8")
    assert os.access(p, os.R_OK) is True

Gotchas

REPL Inspect

from os import access
help(access)

Linked from

Related notes