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

genericpath.isfile

Prev: genericpath.isdir | Up: genericpath | Next: genericpath.isjunction
Rel: genericpath.commonprefix, genericpath.exists, genericpath.getatime, genericpath.getctime
Ref: docs.python.org — genericpath.isfile
Tags: #public #python3 #stdlib #genericpath


Import

import genericpath
from genericpath import isfile

Signature & Overview

genericpath.isfile(path)

Test whether a path is a regular file

Usage

import os
from pathlib import Path
import tempfile

with tempfile.TemporaryDirectory() as tmp:
    p = Path(tmp) / "a.txt"
    p.write_text("hi")
    assert os.path.isfile(p) is True and os.path.isfile(tmp) is False

Gotchas

REPL Inspect

from genericpath import isfile
help(isfile)

Linked from

Related notes